-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update the email template and add pug for templating (#689)
- Loading branch information
1 parent
4d2a901
commit bd3bf70
Showing
5 changed files
with
311 additions
and
11 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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
import * as NodeMailer from "nodemailer" | ||
import path from "path" | ||
import { compileFile } from "pug" | ||
|
||
const TEMPLATE_BASE_PATH = path.join(__dirname, "..", "templates") | ||
|
||
const transporter = NodeMailer.createTransport({ | ||
service: "Gmail", | ||
|
@@ -16,20 +20,29 @@ export default class MailService { | |
* Sends an email to the user confirming their booking was made and specifying the dates | ||
* | ||
* @param recipientEmail the email for which the confirmation should be sent | ||
* @param recipientName the **full** name of the intended recipient | ||
* @param startDateString the pre-formatted date **string** of the *first* **night** in the user's booking | ||
* @param endDateString the pre-formatted date **string** of the *last* **night** in the user's booking | ||
*/ | ||
public async sendBookingConfirmationEmail( | ||
recipientEmail: string, | ||
recipientName: string, | ||
startDateString: string, | ||
endDateString: string | ||
) { | ||
const compiledFunction = compileFile( | ||
`${TEMPLATE_BASE_PATH}/BookingConfirmation.pug` | ||
) | ||
|
||
const info = await transporter.sendMail({ | ||
from: '"UASC Bookings"', | ||
to: recipientEmail, | ||
subject: `Your booking from ${startDateString} to ${endDateString}`, | ||
html: `<p> | ||
Your booking from <strong>${startDateString}</strong> to <strong>${endDateString}</strong> has been confirmed. | ||
Please email <a href="mailto:[email protected]">[email protected]</a> for any queries | ||
</p>` | ||
html: compiledFunction({ | ||
name: recipientName, | ||
startDate: startDateString, | ||
endDate: endDateString | ||
}) | ||
}) | ||
|
||
console.log("Booking confirmation email sent: %s", info.messageId) | ||
|
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
30 changes: 30 additions & 0 deletions
30
server/src/business-layer/templates/BookingConfirmation.pug
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
p Kia ora #{name} | ||
|
||
p UASC is stoked to confirm your booking for an unforgettable stay at your lodge between the nights of: | ||
|
||
p <strong>#{startDate} to #{endDate}</strong> | ||
|
||
p Here's some info for both new and old members: | ||
|
||
p <strong>Getting to our lodge</strong> - Our lodge is nestled on the whakapapa side of Ruapehu, it is a 4 hour drive from Auckland. The drive up Bruce road to the lodge can be snow joke, please drive to the conditions and check Bruce roads status on the whakapapa website before departing. | ||
|
||
p <strong>Parking</strong> - Parking is available on the same road as the lodge. Parking can be hard to find from mid morning to afternoon. You can repark closer to the lodge later in the evening. | ||
|
||
p <strong>Getting into our lodge</strong> - The door code is <strong>1627Y</strong> then turn the handle anticlockwise. | ||
|
||
p <strong>The Lodge</strong> - If this is your first time, welcome to your new home. The bottom floor houses the kitchen, lounge, conversation pit, drying and tuning room. Upstairs you’ll find two bunk rooms and bathrooms, feel free to find a spare bunk and set yourself up. Our lodge custodian, Issac, will be on hand to look after the lodge and answer any questions you might have. | ||
|
||
p <strong>Food</strong> - Dinner is provided | ||
|
||
p <strong>Expectations</strong> - To keep our lodge in top shape, we ask all guests to pitch in with chores. When you see Issac, be proactive and ask what needs doing. Please make sure to leave the lodge as clean (or cleaner!) than you found it. | ||
|
||
p By staying at our lodge you are agreeing to our policy and behavior rules, which you can find in detail on our website. | ||
|
||
p If at any point during your stay you feel unsafe, uncomfortable or want to report something please use our form below which is monitored by our wellbeing officer. | ||
<a href="https://forms.gle/UTBB4TsMCTgyaatYA">https://forms.gle/UTBB4TsMCTgyaatYA</a> | ||
|
||
p Cheers, | ||
p Dominic Chanwai | ||
p University of Auckland Snowsports Club | ||
p Instagram: uasc_nz | Email: <a href="mailto:[email protected]">[email protected]</a> | Website: <a href="https://uasc.co.nz">uasc.co.nz</a> | ||
|
Oops, something went wrong.