From bcb09bb0a053164771e7294db1472a1f7b3a9249 Mon Sep 17 00:00:00 2001 From: pm3512 Date: Tue, 16 Jan 2024 08:09:03 -0500 Subject: [PATCH] added admission email template --- src/controllers/EmailController.ts | 31 +++++++--- src/controllers/UsersController.ts | 10 ++-- src/email-templates/admission/index.mjml | 76 ++++++++++++++++++++++++ src/email-templates/admission/index.ts | 8 +++ src/email-templates/index.ts | 2 + 5 files changed, 113 insertions(+), 14 deletions(-) create mode 100644 src/email-templates/admission/index.mjml create mode 100644 src/email-templates/admission/index.ts diff --git a/src/controllers/EmailController.ts b/src/controllers/EmailController.ts index b0fc429..c87297f 100644 --- a/src/controllers/EmailController.ts +++ b/src/controllers/EmailController.ts @@ -71,16 +71,29 @@ export const sendRecruiterCreationEmail = async ( export const sendStatusUpdateEmail = async ( email: string, name: string, + admitted: boolean, redirectUrl?: string ): Promise => { const url = redirectUrl ?? `${process.env.FRONTEND_URL}`; - await sendTemplateEmail( - [email], - "[TartanHacks] Update regarding your application", - "status-update", - { - name, - url, - } - ); + if (admitted) { + await sendTemplateEmail( + [email], + "[TartanHacks] You have been accepted to TartanHacks!", + "admission", + { + name, + url, + } + ); + } else { + await sendTemplateEmail( + [email], + "[TartanHacks] Update regarding your application", + "status-update", + { + name, + url, + } + ); + } }; diff --git a/src/controllers/UsersController.ts b/src/controllers/UsersController.ts index 14ef16d..4654f6e 100644 --- a/src/controllers/UsersController.ts +++ b/src/controllers/UsersController.ts @@ -127,7 +127,7 @@ export const admitUser = async (req: Request, res: Response): Promise => { }); await user.setStatus(Status.ADMITTED); - await sendStatusUpdateEmail(user.email, profile?.firstName ?? "hacker"); + await sendStatusUpdateEmail(user.email, profile?.firstName ?? "hacker", true); res.status(200).send(); } catch (err) { res.status(500).json(err); @@ -152,7 +152,7 @@ export const admitAllCMU = async ( user: user._id, event: tartanhacks._id, }); - await sendStatusUpdateEmail(user.email, profile?.firstName ?? "hacker"); + await sendStatusUpdateEmail(user.email, profile?.firstName ?? "hacker", true); }; promises.push(promise()); } @@ -190,7 +190,7 @@ export const admitAllUsers = async ( user: user._id, event: tartanhacks._id, }); - await sendStatusUpdateEmail(user.email, profile?.firstName ?? "hacker"); + await sendStatusUpdateEmail(user.email, profile?.firstName ?? "hacker", true); }; promises.push(promise()); } @@ -228,7 +228,7 @@ export const rejectAllUsers = async ( user: user._id, event: tartanhacks._id, }); - await sendStatusUpdateEmail(user.email, profile?.firstName ?? "hacker"); + await sendStatusUpdateEmail(user.email, profile?.firstName ?? "hacker", false); }; promises.push(promise); } @@ -262,7 +262,7 @@ export const rejectUser = async ( user: user._id, }); await user.setStatus(Status.REJECTED); - await sendStatusUpdateEmail(user.email, profile?.firstName ?? "hacker"); + await sendStatusUpdateEmail(user.email, profile?.firstName ?? "hacker", false); res.status(200).send(); } catch (err) { res.status(500).json(err); diff --git a/src/email-templates/admission/index.mjml b/src/email-templates/admission/index.mjml new file mode 100644 index 0000000..0ba7824 --- /dev/null +++ b/src/email-templates/admission/index.mjml @@ -0,0 +1,76 @@ + + + + .rounded-button a { border-radius: 10px; box-shadow: 0 4px 6px hsla(0, 0%, + 46%, 0.2), 0 1px 3px hsla(0, 0%, 46%, 0.2); } + + + @import + url('https://fonts.googleapis.com/css2?family=Poppins:wght@300&display=swap'); + + + + + + + TartanHacks + + + Hey {{name}}, + + + After reviewing your skills and qualifications, we are pleased to inform you that your application to TartanHacks has been accepted! To confirm your attendance, please access the TartanHacks portal here. You will have 5 days from the receipt of this email to confirm your participation. + + + Access Portal + + + We’ll be sending out more details closer to the hackathon date (February 2-3). If you need venue and schedule information, please refer to our website tartanhacks.com. For those who need to travel to Pittsburgh, we would like to remind you that unfortunately we are unable to provide any travel reimbursement this year. If you have any questions or concerns, feel free to reach out to us at tartanhacks@scottylabs.org. + + + We look forward to seeing you at TartanHacks! + + + Best regards, +
+ TartanHacks Organizing Team +
+
+
+
+
diff --git a/src/email-templates/admission/index.ts b/src/email-templates/admission/index.ts new file mode 100644 index 0000000..ce2857d --- /dev/null +++ b/src/email-templates/admission/index.ts @@ -0,0 +1,8 @@ +import mjml2html from "mjml"; +import fs from "fs"; +import path from "path"; + +const text = fs.readFileSync(path.resolve(__dirname, "./index.mjml"), { + encoding: "utf-8", +}); +export default mjml2html(text).html; diff --git a/src/email-templates/index.ts b/src/email-templates/index.ts index ddd1e02..d6934e4 100644 --- a/src/email-templates/index.ts +++ b/src/email-templates/index.ts @@ -2,10 +2,12 @@ import verification from "./verification"; import passwordReset from "./password-reset"; import recruiterSignup from "./recruiter-signup"; import statusUpdate from "./status-update"; +import admission from "./admission" export default { verification, "password-reset": passwordReset, "recruiter-signup": recruiterSignup, "status-update": statusUpdate, + "admission": admission } as Record;