-
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.
* created new photos folder with email footnote and created emailrequestcreated sendgrid function * adding getTotalBoxesDelivered function for Wix live update * fixed controller function to return a json with count as a var rather than just an int * encoded image as 64bit string but doesn't work * added sendgrid emails for all the emails that BoB wanted * added email to chapter after birthday request created --------- Co-authored-by: kygchng <[email protected]>
- Loading branch information
1 parent
5dc470e
commit 970b830
Showing
8 changed files
with
266 additions
and
11 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
*/ | ||
import 'dotenv/config'; | ||
import SGmail, { MailDataRequired } from '@sendgrid/mail'; | ||
// @ts-ignore | ||
import footnote from '../../photos/email_footnote.txt'; | ||
|
||
const appName = 'Boilerplate'; // Replace with a relevant project name | ||
const senderName = 'Hack4Impact UPenn'; // Replace with a relevant project sender | ||
|
@@ -128,10 +130,172 @@ const emailRequestDelete = async (email: string, childName: string) => { | |
await SGmail.send(mailSettings); | ||
}; | ||
|
||
const emailRequestCreate = async (email: string, childName: string) => { | ||
const mailSettings: MailDataRequired = { | ||
from: { | ||
email: process.env.SENDGRID_EMAIL_ADDRESS || '[email protected]', | ||
name: 'Box of Balloons, Inc.', | ||
}, | ||
to: email, | ||
subject: 'Box of Balloons Request Received!', | ||
html: ` | ||
<p>Hello,</p> | ||
<p>Thank you for your request. Box of Balloons has received your request and you will receive a | ||
response when your request is either approved or denied by your local chapter leader.</p> | ||
<p>If you have any specific questions in the meantime, please reach out to your local chapter by | ||
finding their contact information <a href="https://www.boxofballoons.org/where-are-we-1">here</a>.</p> | ||
<p>We appreciate your patience as all our chapters are run 100% by volunteers so response time, | ||
while often quick, may sometimes be delayed.</p> | ||
<p>Thank you,</p> | ||
<p>Box of Balloons, Inc. - Automated response</p> | ||
`, | ||
}; | ||
|
||
//<img src='data:image/png;base64,${footnote}' alt="Box of Balloons Logo" style="max-width: 100%; height: auto;"/> | ||
|
||
// Send the email and propagate the error up if one exists | ||
await SGmail.send(mailSettings); | ||
}; | ||
|
||
const emailRequestApproved = async (email: string, childName: string) => { | ||
const mailSettings: MailDataRequired = { | ||
from: { | ||
email: process.env.SENDGRID_EMAIL_ADDRESS || '[email protected]', | ||
name: 'Box of Balloons, Inc.', | ||
}, | ||
to: email, | ||
subject: 'Box of Balloons Request Approved!', | ||
html: ` | ||
<p>Hello,</p> | ||
<p>Congratulations, let the celebrations begin!! Your request for a birthday box has | ||
been approved by your local volunteer-led chapter of Box of Balloons, Inc.</p> | ||
<p>Please watch out for an email or phone call from your local volunteer chapter | ||
leader with instructions on how your box will be delivered.</p> | ||
<p>If you have any specific questions in the meantime, please reach out to your local chapter by | ||
finding their contact information <a href="https://www.boxofballoons.org/where-are-we-1">here</a>.</p> | ||
<p>Thank you,</p> | ||
<p>Box of Balloons, Inc. - Automated response</p> | ||
`, | ||
}; | ||
await SGmail.send(mailSettings); | ||
}; | ||
|
||
const emailRequestDenied = async (email: string, childName: string) => { | ||
const mailSettings: MailDataRequired = { | ||
from: { | ||
email: process.env.SENDGRID_EMAIL_ADDRESS || '[email protected]', | ||
name: 'Box of Balloons, Inc.', | ||
}, | ||
to: email, | ||
subject: 'Box of Balloons Request Denied', | ||
html: ` | ||
<p>Hello,</p> | ||
<p>Thank you for your request. Unfortunately, your local chapter is unable to fulfill your request | ||
for a birthday box at this time.</p> | ||
<p>As an organization run 100% by volunteers, our ability to accept every request submitted is sometimes | ||
limited by availability and we apologize for the inconvenience this may cause to the families you serve.</p> | ||
<p>We encourage you to reach out to your chapter leaders to explore future opportunities by emailing them | ||
directly. You may find their contact information <a href="https://www.boxofballoons.org/where-are-we-1">here</a>.</p> | ||
<p>Regretfully,</p> | ||
<p>Box of Balloons, Inc. - Automated response</p> | ||
`, | ||
}; | ||
await SGmail.send(mailSettings); | ||
}; | ||
|
||
const emailRequestDelivered = async (email: string, childName: string) => { | ||
const mailSettings: MailDataRequired = { | ||
from: { | ||
email: process.env.SENDGRID_EMAIL_ADDRESS || '[email protected]', | ||
name: 'Box of Balloons, Inc.', | ||
}, | ||
to: email, | ||
subject: 'Box of Balloons Request Delivered!', | ||
html: ` | ||
<p>Cue the Confetti!</p> | ||
<p>The box you have requested on behalf of the families you serve has been delivered! Our goal is to | ||
ensure every child feels celebrated on their birthday and we are so thrilled to be able to provide our | ||
services to the families your agency helps.</p> | ||
<p>As an organization run mostly by volunteers, while our overhead is small compared to other larger | ||
nonprofits, we still have overhead to cover the costs of running a nonprofit. To help us ensure each | ||
birthday is happy and every child is celebrated we invite you to consider helping us spread more joy | ||
to organizations like yours and the families you serve.</p> | ||
<p>Please consider making a donation today, no amount is too small - <a href="https://boxofballoons.networkforgood.com/">Donate Now</a></p> | ||
<p>Other ways to contribute to our mission is by encouraging the family we provided a birthday box to, to send us an email or write a letter | ||
sharing how impactful our service was to them and their child/children. Letters, thank you cards, and especially pictures can be a catalyst | ||
in supporting our mission.</p> | ||
<p>If it is safe to do so and the family assisted is comfortable doing so, we ask that these small but large displays of gratitude be emailed | ||
to: <a href="[email protected]">[email protected]</a> or mailed to P.O. Box 28, Sun Prairie WI. 53590.</p> | ||
<p>Please note any pictures received will be used to advance our fundraising efforts, if a child's identity needs to be hidden please note so | ||
in the email or letter and an emoji will be used to protect the family and child/ren served.</p> | ||
<p>Thank you again for everything you do to make our community a better place for children and families in need. We are in this together!</p> | ||
<p>Here to serve,</p> | ||
<p>Box of Balloons, Inc. Volunteer Team</p> | ||
`, | ||
}; | ||
|
||
//<img src='data:image/png;base64,${footnote}' alt="Box of Balloons Logo" style="max-width: 100%; height: auto;"/> | ||
|
||
// Send the email and propagate the error up if one exists | ||
await SGmail.send(mailSettings); | ||
}; | ||
|
||
const emailChapterRequestCreate = async (email: string, childName: string) => { | ||
const mailSettings: MailDataRequired = { | ||
from: { | ||
email: process.env.SENDGRID_EMAIL_ADDRESS || '[email protected]', | ||
name: 'Box of Balloons, Inc.', | ||
}, | ||
to: email, | ||
subject: 'New Birthday Box Request Received', | ||
html: ` | ||
<p>Hello,</p> | ||
<p>A new birthday box request has been submitted for ${childName}. Please review this request | ||
in your dashboard and either approve or deny it.</p> | ||
<p>Thank you for your dedication to making birthdays special!</p> | ||
<p>Box of Balloons, Inc. - Automated response</p> | ||
`, | ||
}; | ||
|
||
await SGmail.send(mailSettings); | ||
}; | ||
|
||
export { | ||
emailVerificationLink, | ||
emailResetPasswordLink, | ||
emailInviteLink, | ||
emailRequestUpdate, | ||
emailRequestDelete, | ||
emailRequestCreate, | ||
emailRequestApproved, | ||
emailRequestDenied, | ||
emailRequestDelivered, | ||
emailChapterRequestCreate, | ||
}; |