Skip to content

Commit

Permalink
fix: flagged transaction email is cut off (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
RubenLWF authored Oct 13, 2024
1 parent 37a93e2 commit e5bb95a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
1 change: 1 addition & 0 deletions apps/dashboard/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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='[email protected]'
VITE_GIT_COMMIT_BRANCH=''
VITE_GIT_COMMIT_SHA=''
# Where the local api requests should be proxied to
Expand Down
29 changes: 15 additions & 14 deletions apps/dashboard/src/utils/mailUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,34 @@ import { formatPrice } from '@/utils/formatterUtils';

export function sendEmail(transactionInfo: TransactionResponse, productsInfo: Array<SubTransactionRowResponse>)
{
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 {
return import.meta.env.VITE_APP_TREASURER_EMAIL;
}

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<SubTransactionRowResponse>): 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 {
Expand All @@ -47,7 +48,7 @@ function formatProducts(productsInfo: Array<SubTransactionRowResponse>): string
returnString += product.amount + "x "
+ product.product.name + " @ "
+ formatPrice(product.product.priceInclVat) + " = "
+ formatPrice(product.totalPriceInclVat) + "%0D%0A";
+ formatPrice(product.totalPriceInclVat) + "\n";
});

return returnString;
Expand Down

0 comments on commit e5bb95a

Please sign in to comment.