From e5bb95a6b322a3b3a862d99c0ea67489269859ee Mon Sep 17 00:00:00 2001 From: Ruben Lagerwerf <98549214+RubenLWF@users.noreply.github.com> Date: Sun, 13 Oct 2024 14:04:37 +0200 Subject: [PATCH] fix: flagged transaction email is cut off (#365) --- apps/dashboard/.env.example | 1 + apps/dashboard/src/utils/mailUtil.ts | 29 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/apps/dashboard/.env.example b/apps/dashboard/.env.example index 9455a5d2..131e921d 100644 --- a/apps/dashboard/.env.example +++ b/apps/dashboard/.env.example @@ -3,6 +3,7 @@ VITE_APP_IMAGE_BASE='https://sudosos.test.gewis.nl/static/' VITE_APP_GEWIS_TOKEN=sudosos-dev VITE_APP_STRIPE_PUBLISHABLE_KEY='pk_test_51GsQ83CTbnWP3CTYRobkOgrA4EjkHqvAN6FpDCccxfXayLzj4prFU0GeMIefYW0pvdwXuXqpmqJVLnf6bUyvNJ2T009bK0Sn1L' VITE_APP_STRIPE_RETURN_URL='http://localhost:5173/' +VITE_APP_TREASURER_EMAIL='test@test.com' VITE_GIT_COMMIT_BRANCH='' VITE_GIT_COMMIT_SHA='' # Where the local api requests should be proxied to diff --git a/apps/dashboard/src/utils/mailUtil.ts b/apps/dashboard/src/utils/mailUtil.ts index aaa5048c..5d53bd44 100644 --- a/apps/dashboard/src/utils/mailUtil.ts +++ b/apps/dashboard/src/utils/mailUtil.ts @@ -4,9 +4,9 @@ import { formatPrice } from '@/utils/formatterUtils'; export function sendEmail(transactionInfo: TransactionResponse, productsInfo: Array) { - window.open("mailto:" + getEmail() - + "?subject=" + getSubject(transactionInfo) - + "&body="+ getBody(transactionInfo, productsInfo)); + window.open(`mailto:${getEmail()} + ?subject=${getSubject(transactionInfo)} + &body=${getBody(transactionInfo, productsInfo)}`); } function getEmail(): string { @@ -14,23 +14,24 @@ function getEmail(): string { } function getSubject(transactionInfo: TransactionResponse): string { - return "[FLAGGED TRANSACTION] " + return encodeURIComponent("[FLAGGED TRANSACTION] " + transactionInfo.from.firstName + " " + transactionInfo.from.lastName + " " - + getTime(transactionInfo); + + getTime(transactionInfo)); } function getBody(transactionInfo: TransactionResponse, productsInfo: Array): string { - return "Transaction Id: " + transactionInfo.id + "%0D%0A" + return encodeURIComponent("Transaction Id: " + transactionInfo.id + "\n" + "Transaction for: " + transactionInfo.from.firstName + " " - + transactionInfo.from.lastName + " (" + transactionInfo.from.id + ")%0D%0A" + + transactionInfo.from.lastName + " (" + transactionInfo.from.id + ")\n" + "Transaction by: " + transactionInfo.createdBy!.firstName - + " " + transactionInfo.createdBy!.lastName + " (" + transactionInfo.createdBy!.id + ")%0D%0A" - + "Transaction at: " + transactionInfo.pointOfSale.name + "%0D%0A" - + "%0D%0AProducts in transaction: " + "%0D%0A" + formatProducts(productsInfo) - + "________________________%0D%0A" - + "DO NOT CHANGE ANY OF THE ABOVE INFO%0D%0A" - + "Please add any additional information below:%0D%0A"; + + " " + transactionInfo.createdBy!.lastName + " (" + transactionInfo.createdBy!.id + ")\n" + + "Transaction at: " + transactionInfo.pointOfSale.name + "\n" + + "\nProducts in transaction: \n" + + formatProducts(productsInfo) + + "________________________\n" + + "DO NOT CHANGE ANY OF THE ABOVE INFO\n" + + "Please add any additional information below:\n"); } function getTime(transactionInfo: TransactionResponse): string { @@ -47,7 +48,7 @@ function formatProducts(productsInfo: Array): string returnString += product.amount + "x " + product.product.name + " @ " + formatPrice(product.product.priceInclVat) + " = " - + formatPrice(product.totalPriceInclVat) + "%0D%0A"; + + formatPrice(product.totalPriceInclVat) + "\n"; }); return returnString;