Skip to content

Commit

Permalink
Merge pull request #14 from icefoganalytics/main
Browse files Browse the repository at this point in the history
Fixing for env missing
  • Loading branch information
datajohnson authored Jul 3, 2024
2 parents c6c1166 + 8b01066 commit fa73201
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions api/src/services/email-service.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import nodemailer, { Transporter, TransportOptions } from "nodemailer";
import { MailOptions } from "nodemailer/lib/json-transport";
import { MAIL_CONFIG, MAIL_FROM, FRONTEND_URL, APPLICATION_NAME } from "../config";
import { MAIL_CONFIG, MAIL_FROM, APPLICATION_NAME } from "../config";
import fs from "fs";
import path from "path";
import { Incident } from "src/data/models";

const FRONTEND_OVERRIDE = "https://safety.gov.yk.ca"

const BASE_TEMPLATE = "../templates/email/base.html";
const INCIDENT_EMPLOYEE_TEMPLATE = "../templates/email/incident-notification-employee.html";
const INCIDENT_REPORTER_TEMPLATE = "../templates/email/incident-notification-reporter.html";
Expand Down Expand Up @@ -38,7 +40,7 @@ export class EmailService {
let content = fs.readFileSync(templatePath).toString();

content = content.replace(/``REPORTING_NAME``/g, employeeName ?? "");
content = content.replace(/``INCIDENT_URL``/g, `${FRONTEND_URL}/reports/${incident.id}`);
content = content.replace(/``INCIDENT_URL``/g, `${FRONTEND_OVERRIDE}/reports/${incident.id}`);

console.log("-- EMAIL REPORTER INCIDENT NOTIFICATION", recipient.email);

Expand All @@ -54,7 +56,7 @@ export class EmailService {
let content = fs.readFileSync(templatePath).toString();

content = content.replace(/``REPORTING_NAME``/g, employeeName ?? "");
content = content.replace(/``INCIDENT_URL``/g, `${FRONTEND_URL}/reports/${incident.id}`);
content = content.replace(/``INCIDENT_URL``/g, `${FRONTEND_OVERRIDE}/reports/${incident.id}`);

console.log("-- EMAIL EMPLOYEE INCIDENT NOTIFICATION", recipient.email);

Expand All @@ -70,7 +72,7 @@ export class EmailService {
let content = fs.readFileSync(templatePath).toString();

content = content.replace(/``REPORTING_NAME``/g, employeeName ?? "");
content = content.replace(/``INCIDENT_URL``/g, `${FRONTEND_URL}/reports/${incident.id}`);
content = content.replace(/``INCIDENT_URL``/g, `${FRONTEND_OVERRIDE}/reports/${incident.id}`);

console.log("-- EMAIL SUPERVISOR INCIDENT NOTIFICATION", recipient.email);

Expand All @@ -82,7 +84,7 @@ export class EmailService {
let baseContent = fs.readFileSync(basePath).toString();

baseContent = baseContent.replace(/``CUSTOM_CONTENT``/, customContent);
baseContent = baseContent.replace(/``APPLICATION_URL``/g, FRONTEND_URL);
baseContent = baseContent.replace(/``APPLICATION_URL``/g, FRONTEND_OVERRIDE);
baseContent = baseContent.replace(/``APPLICATION_NAME``/g, APPLICATION_NAME);
baseContent = baseContent.replace(/``TO_NAME``/g, toName);
baseContent = baseContent.replace(/``TO_EMAIL``/g, toEmail);
Expand Down
2 changes: 1 addition & 1 deletion web/src/layouts/DefaultNoAuth.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ onMounted(async () => {
});
async function logoutClick() {
await AuthHelper.logout();
await AuthHelper.logout({ returnTo: "https://safety.gov.yk.ca" });
}
async function loginClick() {
Expand Down

0 comments on commit fa73201

Please sign in to comment.