Skip to content

Commit

Permalink
added admission email template
Browse files Browse the repository at this point in the history
  • Loading branch information
pm3512 committed Jan 16, 2024
1 parent e181e20 commit bcb09bb
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 14 deletions.
31 changes: 22 additions & 9 deletions src/controllers/EmailController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,29 @@ export const sendRecruiterCreationEmail = async (
export const sendStatusUpdateEmail = async (
email: string,
name: string,
admitted: boolean,
redirectUrl?: string
): Promise<void> => {
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,
}
);
}
};
10 changes: 5 additions & 5 deletions src/controllers/UsersController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const admitUser = async (req: Request, res: Response): Promise<void> => {
});

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);
Expand All @@ -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());
}
Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down
76 changes: 76 additions & 0 deletions src/email-templates/admission/index.mjml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<mjml>
<mj-head>
<mj-style>
.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); }
</mj-style>
<mj-style>
@import
url('https://fonts.googleapis.com/css2?family=Poppins:wght@300&display=swap');
</mj-style>
</mj-head>
<mj-body>
<mj-section border="solid black 1px" background-color="#fff">
<mj-column width="80%">
<mj-text
align="center"
color="#000"
font-size="40px"
font-family="Poppins, sans-serif"
>
TartanHacks
</mj-text>
<mj-text
align="left"
color="#000"
font-size="12px"
font-family="Poppins, sans-serif"
>
Hey {{name}},
</mj-text>
<mj-text
align="left"
color="#000"
font-size="12px"
font-family="Poppins, sans-serif"
>
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 <a href="{{url}}">here</a>. You will have 5 days from the receipt of this email to confirm your participation.
</mj-text>
<mj-button
background-color="#ff7aa5"
href="{{url}}"
font-family="Poppins, sans-serif"
css-class="rounded-button"
>
Access Portal
</mj-button>
<mj-text
align="left"
color="#000"
font-size="12px"
font-family="Poppins, sans-serif"
>
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 <a href="tartanhacks.com">tartanhacks.com</a>. 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 <a href="mailto:[email protected]">[email protected]</a>.
</mj-text>
<mj-text
align="left"
color="#000"
font-size="12px"
font-family="Poppins, sans-serif"
>
We look forward to seeing you at TartanHacks!
</mj-text>
<mj-text
align="left"
color="#000"
font-size="12px"
font-family="Poppins, sans-serif"
>
Best regards,
<br>
TartanHacks Organizing Team
</mj-text>
</mj-column>
</mj-section>
</mj-body>
</mjml>
8 changes: 8 additions & 0 deletions src/email-templates/admission/index.ts
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 2 additions & 0 deletions src/email-templates/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string>;

0 comments on commit bcb09bb

Please sign in to comment.