Skip to content

Commit

Permalink
reformatted emailing templates and removed catchment contact emailinf
Browse files Browse the repository at this point in the history
  • Loading branch information
npham49 committed Oct 6, 2023
1 parent 4dc14bb commit f7cddcd
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 68 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ module.exports = {
"@typescript-eslint/no-shadow": "off",
"no-await-in-loop": "off",
"no-continue": "off",
"no-restricted-syntax": "off"
"no-restricted-syntax": "off",
"no-console": "off"
},
ignorePatterns: ["**/dist/**/*.js"]
}
14 changes: 14 additions & 0 deletions packages/employer-api/src/config/CREATE_SCRIPTS.sql
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,17 @@ TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.employers_claims
OWNER to postgres;


CREATE TABLE IF NOT EXISTS public.notifications
(
id character varying(255) COLLATE pg_catalog."default" NOT NULL,
email character varying(255) COLLATE pg_catalog."default",
catchmentno integer
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.notifications
OWNER to postgres;

73 changes: 7 additions & 66 deletions packages/form-api/src/controllers/email.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,16 @@
import * as express from "express"

import * as emailService from "../services/email.service"
import { knex } from "../config/db-config"
import { getToken } from "../services/common.service"

// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
const generateHTMLEmail = require("../utils/htmlEmail")

const s3static = process.env.S3_STATIC_IMG_URL || ""
import received from "../templates/received.template"

const createEmail = (data: any) => {
let emailHTML: string
let emailHTML = ""
// in case of employee email, it is have employee application
if (data.employeeEmail0) {
emailHTML = generateHTMLEmail(
"WorkBC Wage Subsidy Application - Next Steps",
[
`Hello,`,
`You’re receiving this email because your future employer recently applied for a WorkBC Wage Subsidy.`,
`WorkBC is a provincial government service that helps residents of B.C. improve their skills, explore career options, and find employment.`
],
[
`Only a few steps remain before you are back at work.`,
`If you are participating in WorkBC Services, contact your Employment Counsellor right away, before taking the steps below.`,
`If you are NOT already participating in WorkBC Services, please follow these steps:`,
`<b>Step 1:</b> Register for Online Employment Services.`,
`<b>Step 2:</b> Complete an online application. Click <a href="https://apply.workbc.ca/">here</a> to get started and ensure you <b>select WorkBC Self-Serve<b> to begin your application.`,
`<img class="img-fluid" src="${s3static}/wage-subsidy-images/workbc_self_serve.png" alt="WorkBC Self Serve Option" style="height: auto; line-height: 100%; outline: none; text-decoration: none; width: 100%; max-width: 100%; border: 0 none;">`,
`When selecting your WorkBC Centre, select the community where your job is located.`,
`<img class="img-fluid" src="${s3static}/wage-subsidy-images/workbc_community_select.png" alt="WorkBC Community Selector" style="height: auto; line-height: 100%; outline: none; text-decoration: none; width: 100%; max-width: 100%; border: 0 none;">`,
`<b>Step 3:</b> Let your employer know you have applied! A team member will be in touch soon.`
],
[
`<b>Why use WorkBC?</b></p><p>
<ul>
<li>
<b>Expertise: </b>We're ready to help you start career planning now or get you ready for the next phase of BC's COVID-19 Restart Plan.</li>
<li>
<b>Free Services: </b>We offer skills training and personalized, one-on-one job counselling. WorkBC services are completely free.</li>
<li>
<b>Benefits: </b>You might also be eligible for exclusive benefits.</li>
</ul>
`,
`Sincerely,<br><b>Your WorkBC team<br></b>`
]
)
emailHTML = received.receivedHaveEmployee()
// in case of no employee email, it is need employee application
} else if (data.positionTitle0 && data.employeeEmail0 === undefined) {
emailHTML = generateHTMLEmail(
"Thank you, your application has been received",
[
`Thank you for your interest in WorkBC Wage Subsidy services.`,
`A WorkBC staff member will be in touch with you to confirm your business qualifies for WorkBC Wage subsidy, to complete the application process and will work with you on identifying a suitable match.`
],
[],
[]
)
} else {
emailHTML = generateHTMLEmail(
"A Wage Subsidy Claim Application has been submitted",
[
`<b>Catchment: ${data.container.workbcCentre.split("-")[0]}</b>`,
`Thank you for your interest in WorkBC Wage Subsidy services.`
],
[],
[]
)
emailHTML = received.receivedNeedEmployee()
}
return emailHTML
}
Expand Down Expand Up @@ -94,16 +41,10 @@ export const sendEmail = async (req: any, res: express.Response) => {
.filter((email: string) => email !== null)
.filter((v: string, i: number, a: string[]) => a.indexOf(v) === i)
}
if (data.container?.workbcCentre && data.employeeEmail0 === undefined) {
const email = await knex("wage_subsidy_catchment_emails")
.where("catchmentno", Number(data.container.workbcCentre.split("-")[0]))
.first()
recipients = email.emailcontact.split(";")
}

const emailHTML = createEmail(data)
if (recipients.length !== 0) {
await emailService.sendEmail(await getToken(), emailHTML, `Wage Subsidy Application Submitted`, recipients)
await emailService.sendEmail(emailHTML, `Wage Subsidy Application Submitted`, recipients)
}
// console.log(email)
return res.status(200).send("Email sent")
Expand Down
5 changes: 4 additions & 1 deletion packages/form-api/src/services/email.service.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/* eslint-disable import/prefer-default-export */
import { AxiosResponse } from "axios"

import { getToken } from "./common.service"

import { chesApi } from "../config/config"

export const sendEmail = async (token: string, body: string, subject: string, to: string[]) => {
export const sendEmail = async (body: string, subject: string, to: string[]) => {
try {
const token = await getToken()
console.log(body)
const request = {
// bcc: [],
Expand Down
58 changes: 58 additions & 0 deletions packages/form-api/src/templates/received.template.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
const generateHTMLEmail = require("../utils/htmlEmail")

const s3static = process.env.S3_STATIC_IMG_URL || ""

const receivedHaveEmployee = () => {
const email = generateHTMLEmail(
"WorkBC Wage Subsidy Application - Next Steps",
[
`Hello,`,
`You’re receiving this email because your future employer recently applied for a WorkBC Wage Subsidy.`,
`WorkBC is a provincial government service that helps residents of B.C. improve their skills, explore career options, and find employment.`
],
[
`Only a few steps remain before you are back at work.`,
`If you are participating in WorkBC Services, contact your Employment Counsellor right away, before taking the steps below.`,
`If you are NOT already participating in WorkBC Services, please follow these steps:`,
`<b>Step 1:</b> Register for Online Employment Services.`,
`<b>Step 2:</b> Complete an online application. Click <a href="https://apply.workbc.ca/">here</a> to get started and ensure you <b>select WorkBC Self-Serve<b> to begin your application.`,
`<img class="img-fluid" src="${s3static}/wage-subsidy-images/workbc_self_serve.png" alt="WorkBC Self Serve Option" style="height: auto; line-height: 100%; outline: none; text-decoration: none; width: 100%; max-width: 100%; border: 0 none;">`,
`When selecting your WorkBC Centre, select the community where your job is located.`,
`<img class="img-fluid" src="${s3static}/wage-subsidy-images/workbc_community_select.png" alt="WorkBC Community Selector" style="height: auto; line-height: 100%; outline: none; text-decoration: none; width: 100%; max-width: 100%; border: 0 none;">`,
`<b>Step 3:</b> Let your employer know you have applied! A team member will be in touch soon.`
],
[
`<b>Why use WorkBC?</b></p><p>
<ul>
<li>
<b>Expertise: </b>We're ready to help you start career planning now or get you ready for the next phase of BC's COVID-19 Restart Plan.</li>
<li>
<b>Free Services: </b>We offer skills training and personalized, one-on-one job counselling. WorkBC services are completely free.</li>
<li>
<b>Benefits: </b>You might also be eligible for exclusive benefits.</li>
</ul>
`,
`Sincerely,<br><b>Your WorkBC team<br></b>`
]
)
return email
}

const receivedNeedEmployee = () => {
const email = generateHTMLEmail(
"Thank you, your application has been received",
[
`Thank you for your interest in WorkBC Wage Subsidy services.`,
`A WorkBC staff member will be in touch with you to confirm your business qualifies for WorkBC Wage subsidy, to complete the application process and will work with you on identifying a suitable match.`
],
[],
[]
)
return email
}

export default {
receivedHaveEmployee,
receivedNeedEmployee
}

0 comments on commit f7cddcd

Please sign in to comment.