Skip to content

Commit

Permalink
v3 eta syntax
Browse files Browse the repository at this point in the history
Signed-off-by: Lucas ONeil <lucasoneil@gmail.com>
  • Loading branch information
loneil committed Jun 29, 2023
1 parent 720960e commit f32bb61
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions services/tenant-ui/src/components/email.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Request } from "express";
import config from "config";
import nodemailer from "nodemailer";
import * as eta from "eta"; // HTML templating engine
import { Eta } from "eta"; // HTML templating engine
import { buildStatusAutofill } from "../helpers";

import { RESERVATION_APPROVED_TENANT_TEMPLATE } from "./email_templates/reservation_approved_tenant";
Expand All @@ -15,6 +15,8 @@ const PORT: number = config.get("server.smtp.port");
const FROM: string = config.get("server.smtp.senderAddress");
const INNKEEPER: string = config.get("server.smtp.innkeeperInbox");

const eta = new Eta();

/**
* @function sendConfirmationEmail
* Send the preconfigured emails when a reservation is created
Expand All @@ -29,7 +31,7 @@ export const sendConfirmationEmail = async (req: Request) => {
});

req.body.serverUrlStatusRouteAutofill = buildStatusAutofill(req.body);
const tenantHtml = eta.render(RESERVATION_RECIEVED_TENANT_TEMPLATE, req);
const tenantHtml = eta.renderString(RESERVATION_RECIEVED_TENANT_TEMPLATE, req);

// Send a confirmation email to the person doing the reservation
await transporter.sendMail({
Expand All @@ -39,7 +41,7 @@ export const sendConfirmationEmail = async (req: Request) => {
html: tenantHtml, // html body
});

const innkeeperHtml = eta.render(
const innkeeperHtml = eta.renderString(
RESERVATION_RECIEVED_INNKEEPER_TEMPLATE,
req
);
Expand Down Expand Up @@ -82,7 +84,7 @@ export const sendStatusEmail = async (req: Request) => {
} else {
throw Error(`Unsupported reservation state: ${req.body.state}`);
}
const tenantHtml = eta.render(template, req);
const tenantHtml = eta.renderString(template, req);

// Send a status update email to the applicant
await transporter.sendMail({
Expand Down

0 comments on commit f32bb61

Please sign in to comment.