generated from hack4impact-upenn/boilerplate-s2022
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix modify order and retail rescue items
- Loading branch information
Ricky Raup
authored and
Ricky Raup
committed
May 17, 2024
1 parent
f7306c7
commit 974dec9
Showing
5 changed files
with
47 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,8 +90,11 @@ const emailInviteLink = async (email: string, token: string) => { | |
|
||
const parseArray = (array: any) => { | ||
return array | ||
.map((element: retailRescueItem) => `${element.item} ${element.comment}`) | ||
.join(); | ||
.map( | ||
(element: retailRescueItem) => | ||
`Item: ${element.item} - Comment: ${element.comment}`, | ||
) | ||
.join(', '); | ||
}; | ||
|
||
const formatOrderToEmail = (order: IOrder) => { | ||
|
@@ -130,6 +133,38 @@ const formatOrderToEmail = (order: IOrder) => { | |
); | ||
}; | ||
|
||
const emailModifyOrder = async (email: string, order: IOrder) => { | ||
const userEmail: MailDataRequired = { | ||
from: { | ||
email: process.env.SENDGRID_EMAIL_ADDRESS || '[email protected]', | ||
name: senderName, | ||
}, | ||
to: order.email, | ||
subject: 'Order Modified', | ||
html: | ||
`<h1 style="color:black;">Your order has been modified</h1>` + | ||
`<h2 style="color:black;">Your order summary:</h2>${formatOrderToEmail( | ||
order, | ||
)}`, | ||
}; | ||
const adminEmail: MailDataRequired = { | ||
from: { | ||
email: process.env.SENDGRID_EMAIL_ADDRESS || '[email protected]', | ||
name: senderName, | ||
}, | ||
to: email, | ||
subject: 'Modified Order', | ||
html: | ||
`<h1 style="color:black;">You modified an order</h1>` + | ||
`<h2 style="color:black;">Order summary:</h2>${formatOrderToEmail( | ||
order, | ||
)}`, | ||
}; | ||
// Send the email and propogate the error up if one exists | ||
await SGmail.send(userEmail); | ||
await SGmail.send(adminEmail); | ||
}; | ||
|
||
const emailApproveOrder = async (email: string, order: IOrder) => { | ||
const userEmail: MailDataRequired = { | ||
from: { | ||
|
@@ -201,4 +236,5 @@ export { | |
emailInviteLink, | ||
emailApproveOrder, | ||
emailRejectOrder, | ||
emailModifyOrder, | ||
}; |