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.
- Loading branch information
Ricky Raup
authored and
Ricky Raup
committed
May 17, 2024
1 parent
974dec9
commit fa1e498
Showing
2 changed files
with
48 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,7 +92,11 @@ const parseArray = (array: any) => { | |
return array | ||
.map( | ||
(element: retailRescueItem) => | ||
`Item: ${element.item} - Comment: ${element.comment}`, | ||
`Item: ${element.item} - Comment: ${ | ||
element.comment === undefined || element.comment.length === 0 | ||
? 'None' | ||
: element.comment | ||
}`, | ||
) | ||
.join(', '); | ||
}; | ||
|
@@ -126,23 +130,27 @@ const formatOrderToEmail = (order: IOrder) => { | |
order.retailRescue, | ||
)}</div>` + | ||
`<div style="color:black;">Status: ${order.status}</div>` + | ||
`<div style="color:black;">Pickup: ${pickupDate.toLocaleTimeString([], { | ||
hour: '2-digit', | ||
minute: '2-digit', | ||
})}</div>` | ||
`<div style="color:black;">Pickup Date: ${pickupDate.toDateString()}</div>` + | ||
`<div style="color:black;">Pickup Time: ${pickupDate.toLocaleTimeString( | ||
[], | ||
{ | ||
hour: '2-digit', | ||
minute: '2-digit', | ||
}, | ||
)}</div>` | ||
); | ||
}; | ||
|
||
const emailModifyOrder = async (email: string, order: IOrder) => { | ||
const emailModifyApproveOrder = 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', | ||
subject: 'Order Modified/Approved', | ||
html: | ||
`<h1 style="color:black;">Your order has been modified</h1>` + | ||
`<h1 style="color:black;">Your order has been modified and approved</h1>` + | ||
`<h2 style="color:black;">Your order summary:</h2>${formatOrderToEmail( | ||
order, | ||
)}`, | ||
|
@@ -153,9 +161,9 @@ const emailModifyOrder = async (email: string, order: IOrder) => { | |
name: senderName, | ||
}, | ||
to: email, | ||
subject: 'Modified Order', | ||
subject: 'Modified/Approved Order', | ||
html: | ||
`<h1 style="color:black;">You modified an order</h1>` + | ||
`<h1 style="color:black;">You modified/approved an order</h1>` + | ||
`<h2 style="color:black;">Order summary:</h2>${formatOrderToEmail( | ||
order, | ||
)}`, | ||
|
@@ -165,6 +173,24 @@ const emailModifyOrder = async (email: string, order: IOrder) => { | |
await SGmail.send(adminEmail); | ||
}; | ||
|
||
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;">You have modified your order</h1>` + | ||
`<h2 style="color:black;">Your order summary:</h2>${formatOrderToEmail( | ||
order, | ||
)}`, | ||
}; | ||
// Send the email and propogate the error up if one exists | ||
await SGmail.send(userEmail); | ||
}; | ||
|
||
const emailApproveOrder = async (email: string, order: IOrder) => { | ||
const userEmail: MailDataRequired = { | ||
from: { | ||
|
@@ -236,5 +262,6 @@ export { | |
emailInviteLink, | ||
emailApproveOrder, | ||
emailRejectOrder, | ||
emailModifyApproveOrder, | ||
emailModifyOrder, | ||
}; |