Skip to content

Commit

Permalink
Merge pull request #1843 from bcgov/feature/ALCS-2140
Browse files Browse the repository at this point in the history
Convert emails to use HTML templates instead of MJML
  • Loading branch information
trslater authored Sep 11, 2024
2 parents a59dc77 + e35407f commit cfea455
Show file tree
Hide file tree
Showing 54 changed files with 641 additions and 1,368 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Mapper } from 'automapper-core';
import { InjectMapper } from 'automapper-nestjs';
import * as config from 'config';
import { ServiceValidationException } from '../../../../../../libs/common/src/exceptions/base.exception';
import { generateINCGApplicationHtml } from '../../../../../../templates/emails/return-to-lfng';
import { template } from '../../../../../../templates/emails/return-to-lfng/application.template';
import { ANY_AUTH_ROLE } from '../../../common/authorization/roles';
import { RolesGuard } from '../../../common/authorization/roles-guard.service';
import { UserRoles } from '../../../common/authorization/roles.decorator';
Expand Down Expand Up @@ -144,7 +144,7 @@ export class ApplicationSubmissionController {
//Send Email
if (primaryContact && submissionGovernment) {
await this.statusEmailService.sendApplicationStatusEmail({
generateStatusHtml: generateINCGApplicationHtml,
template,
status: SUBMISSION_STATUS.RETURNED_TO_LG,
applicationSubmission: submission,
government: submissionGovernment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Test, TestingModule } from '@nestjs/testing';
import { classes } from 'automapper-classes';
import { AutomapperModule } from 'automapper-nestjs';
import { ClsService } from 'nestjs-cls';
import { generateCANCApplicationHtml } from '../../../../../templates/emails/cancelled';
import { template } from '../../../../../templates/emails/cancelled/application.template';
import {
initApplicationMockEntity,
initMockAssigneeDto,
Expand Down Expand Up @@ -426,7 +426,7 @@ describe('ApplicationController', () => {
1,
);
expect(statusEmailService.sendApplicationStatusEmail).toHaveBeenCalledWith({
generateStatusHtml: generateCANCApplicationHtml,
template,
status: SUBMISSION_STATUS.CANCELLED,
applicationSubmission: mockApplicationSubmission,
government: mockGovernment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from '@nestjs/common';
import { ApiOAuth2 } from '@nestjs/swagger';
import * as config from 'config';
import { generateCANCApplicationHtml } from '../../../../../templates/emails/cancelled';
import { template } from '../../../../../templates/emails/cancelled/application.template';
import { ROLES_ALLOWED_APPLICATIONS } from '../../common/authorization/roles';
import { RolesGuard } from '../../common/authorization/roles-guard.service';
import { UserRoles } from '../../common/authorization/roles.decorator';
Expand Down Expand Up @@ -144,7 +144,7 @@ export class ApplicationController {
SUBMISSION_STATUS.IN_PROGRESS
) {
await this.statusEmailService.sendApplicationStatusEmail({
generateStatusHtml: generateCANCApplicationHtml,
template,
status: SUBMISSION_STATUS.CANCELLED,
applicationSubmission,
government: submissionGovernment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ApiOAuth2 } from '@nestjs/swagger';
import { Mapper } from 'automapper-core';
import { InjectMapper } from 'automapper-nestjs';
import * as config from 'config';
import { generateCANCNoticeOfIntentHtml } from '../../../../../templates/emails/cancelled';
import { template } from '../../../../../templates/emails/cancelled/notice-of-intent.template';
import {
ROLES_ALLOWED_APPLICATIONS,
ROLES_ALLOWED_BOARDS,
Expand Down Expand Up @@ -111,7 +111,7 @@ export class NoticeOfIntentController {
NOI_SUBMISSION_STATUS.IN_PROGRESS
) {
await this.statusEmailService.sendNoticeOfIntentStatusEmail({
generateStatusHtml: generateCANCNoticeOfIntentHtml,
template,
status: NOI_SUBMISSION_STATUS.CANCELLED,
noticeOfIntentSubmission,
government: submissionGovernment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { BaseServiceException } from '@app/common/exceptions/base.exception';
import { createMock, DeepMocked } from '@golevelup/nestjs-testing';
import { Test, TestingModule } from '@nestjs/testing';
import { ClsService } from 'nestjs-cls';
import { generateRFFGHtml } from '../../../../../templates/emails/refused-to-forward.template';
import { generateINCMHtml } from '../../../../../templates/emails/returned-as-incomplete.template';
import { generateSUBMApplicationHtml } from '../../../../../templates/emails/submitted-to-alc';
import { generateWRNGHtml } from '../../../../../templates/emails/wrong-lfng.template';
import { template as rffgTemplate } from '../../../../../templates/emails/refused-to-forward.template';
import { template as incmTemplate } from '../../../../../templates/emails/returned-as-incomplete.template';
import { template as submApplicationTemplate } from '../../../../../templates/emails/submitted-to-alc/application.template';
import { template as wrngTemplate } from '../../../../../templates/emails/wrong-lfng.template';
import { mockKeyCloakProviders } from '../../../test/mocks/mockTypes';
import { ApplicationDocument } from '../../alcs/application/application-document/application-document.entity';
import { ApplicationDocumentService } from '../../alcs/application/application-document/application-document.service';
Expand Down Expand Up @@ -381,7 +381,7 @@ describe('ApplicationSubmissionReviewController', () => {
expect(
mockStatusEmailService.sendApplicationStatusEmail,
).toHaveBeenCalledWith({
generateStatusHtml: generateSUBMApplicationHtml,
template: submApplicationTemplate,
status: SUBMISSION_STATUS.SUBMITTED_TO_ALC,
applicationSubmission: mockSubmission,
government: mockLG,
Expand Down Expand Up @@ -456,7 +456,7 @@ describe('ApplicationSubmissionReviewController', () => {
expect(
mockStatusEmailService.sendApplicationStatusEmail,
).toHaveBeenCalledWith({
generateStatusHtml: generateRFFGHtml,
template: rffgTemplate,
status: SUBMISSION_STATUS.REFUSED_TO_FORWARD_LG,
applicationSubmission: mockSubmission,
government: mockLG,
Expand Down Expand Up @@ -559,7 +559,7 @@ describe('ApplicationSubmissionReviewController', () => {
expect(
mockStatusEmailService.sendApplicationStatusEmail,
).toHaveBeenCalledWith({
generateStatusHtml: generateINCMHtml,
template: incmTemplate,
status: SUBMISSION_STATUS.INCOMPLETE,
applicationSubmission: mockSubmission,
government: mockLG,
Expand Down Expand Up @@ -638,7 +638,7 @@ describe('ApplicationSubmissionReviewController', () => {
expect(
mockStatusEmailService.sendApplicationStatusEmail,
).toHaveBeenCalledWith({
generateStatusHtml: generateWRNGHtml,
template: wrngTemplate,
status: SUBMISSION_STATUS.WRONG_GOV,
applicationSubmission: mockSubmission,
government: mockLG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import {
Req,
UseGuards,
} from '@nestjs/common';
import { generateRFFGHtml } from '../../../../../templates/emails/refused-to-forward.template';
import { generateINCMHtml } from '../../../../../templates/emails/returned-as-incomplete.template';
import { generateSUBMApplicationHtml } from '../../../../../templates/emails/submitted-to-alc';
import { generateREVGHtml } from '../../../../../templates/emails/under-review-by-lfng.template';
import { generateWRNGHtml } from '../../../../../templates/emails/wrong-lfng.template';
import { template as rffgTemplate } from '../../../../../templates/emails/refused-to-forward.template';
import { template as incmTemplate } from '../../../../../templates/emails/returned-as-incomplete.template';
import { template as submApplicationTemplate } from '../../../../../templates/emails/submitted-to-alc/application.template';
import { template as revgTemplate } from '../../../../../templates/emails/under-review-by-lfng.template';
import { template as wrngTemplate } from '../../../../../templates/emails/wrong-lfng.template';
import { ApplicationDocumentService } from '../../alcs/application/application-document/application-document.service';
import { ApplicationSubmissionStatusService } from '../../alcs/application/application-submission-status/application-submission-status.service';
import { SUBMISSION_STATUS } from '../../alcs/application/application-submission-status/submission-status.dto';
Expand Down Expand Up @@ -193,7 +193,7 @@ export class ApplicationSubmissionReviewController {

if (primaryContact) {
await this.statusEmailService.sendApplicationStatusEmail({
generateStatusHtml: generateREVGHtml,
template: revgTemplate,
status: SUBMISSION_STATUS.IN_REVIEW_BY_LG,
applicationSubmission,
government: userLocalGovernment,
Expand Down Expand Up @@ -302,7 +302,7 @@ export class ApplicationSubmissionReviewController {

if (primaryContact) {
await this.statusEmailService.sendApplicationStatusEmail({
generateStatusHtml: generateSUBMApplicationHtml,
template: submApplicationTemplate,
status: SUBMISSION_STATUS.SUBMITTED_TO_ALC,
applicationSubmission: submission,
government: userLocalGovernment,
Expand All @@ -320,7 +320,7 @@ export class ApplicationSubmissionReviewController {

if (primaryContact) {
await this.statusEmailService.sendApplicationStatusEmail({
generateStatusHtml: generateRFFGHtml,
template: rffgTemplate,
status: SUBMISSION_STATUS.REFUSED_TO_FORWARD_LG,
applicationSubmission: submission,
government: userLocalGovernment,
Expand Down Expand Up @@ -412,7 +412,7 @@ export class ApplicationSubmissionReviewController {
if (primaryContact) {
if (returnDto.reasonForReturn === 'wrongGovernment') {
await this.statusEmailService.sendApplicationStatusEmail({
generateStatusHtml: generateWRNGHtml,
template: wrngTemplate,
status: SUBMISSION_STATUS.WRONG_GOV,
applicationSubmission,
government: userLocalGovernment,
Expand All @@ -424,7 +424,7 @@ export class ApplicationSubmissionReviewController {

if (returnDto.reasonForReturn === 'incomplete') {
await this.statusEmailService.sendApplicationStatusEmail({
generateStatusHtml: generateINCMHtml,
template: incmTemplate,
status: SUBMISSION_STATUS.INCOMPLETE,
applicationSubmission,
government: userLocalGovernment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ import { classes } from 'automapper-classes';
import { AutomapperModule } from 'automapper-nestjs';
import { ClsService } from 'nestjs-cls';
import { ServiceValidationException } from '../../../../../libs/common/src/exceptions/base.exception';
import { generateCANCApplicationHtml } from '../../../../../templates/emails/cancelled';
import {
generateSUBGNoReviewGovernmentTemplateEmail,
generateSUBGTurApplicantHtml,
} from '../../../../../templates/emails/submitted-to-alc';
import {
generateSUBGApplicantHtml,
generateSUBGGovernmentHtml,
} from '../../../../../templates/emails/submitted-to-lfng';
import { template as cancApplicationTemplate } from '../../../../../templates/emails/cancelled/application.template';
import { template as subgNoReviewGovernmentTemplate } from '../../../../../templates/emails/submitted-to-alc/no-review-government.template';
import { template as subgTurApplicantTemplate } from '../../../../../templates/emails/submitted-to-alc/tur-applicant.template';
import { template as subgApplicantTemplate } from '../../../../../templates/emails/submitted-to-lfng/applicant.template';
import { template as subgGovernmentTemplate } from '../../../../../templates/emails/submitted-to-lfng/government.template';
import { mockKeyCloakProviders } from '../../../test/mocks/mockTypes';
import { ApplicationDocumentService } from '../../alcs/application/application-document/application-document.service';
import { ApplicationSubmissionStatusType } from '../../alcs/application/application-submission-status/submission-status-type.entity';
Expand Down Expand Up @@ -289,7 +285,7 @@ describe('ApplicationSubmissionController', () => {
expect(
mockStatusEmailService.sendApplicationStatusEmail,
).toHaveBeenCalledWith({
generateStatusHtml: generateCANCApplicationHtml,
template: cancApplicationTemplate,
status: SUBMISSION_STATUS.CANCELLED,
applicationSubmission: mockApplication,
government: mockGovernment,
Expand Down Expand Up @@ -531,7 +527,7 @@ describe('ApplicationSubmissionController', () => {
expect(
mockStatusEmailService.sendApplicationStatusEmail,
).toHaveBeenCalledWith({
generateStatusHtml: generateSUBGTurApplicantHtml,
template: subgTurApplicantTemplate,
status: SUBMISSION_STATUS.SUBMITTED_TO_ALC,
applicationSubmission: mockApplicationSubmission,
government: mockGovernment,
Expand All @@ -542,7 +538,7 @@ describe('ApplicationSubmissionController', () => {
expect(
mockStatusEmailService.sendApplicationStatusEmail,
).toHaveBeenCalledWith({
generateStatusHtml: generateSUBGNoReviewGovernmentTemplateEmail,
template: subgNoReviewGovernmentTemplate,
status: SUBMISSION_STATUS.SUBMITTED_TO_ALC,
applicationSubmission: mockApplicationSubmission,
government: mockGovernment,
Expand Down Expand Up @@ -595,7 +591,7 @@ describe('ApplicationSubmissionController', () => {
expect(
mockStatusEmailService.sendApplicationStatusEmail,
).toHaveBeenCalledWith({
generateStatusHtml: generateSUBGApplicantHtml,
template: subgApplicantTemplate,
status: SUBMISSION_STATUS.SUBMITTED_TO_LG,
applicationSubmission: mockApplicationSubmission,
government: mockGovernment,
Expand All @@ -606,7 +602,7 @@ describe('ApplicationSubmissionController', () => {
expect(
mockStatusEmailService.sendApplicationStatusEmail,
).toHaveBeenCalledWith({
generateStatusHtml: generateSUBGGovernmentHtml,
template: subgGovernmentTemplate,
status: SUBMISSION_STATUS.SUBMITTED_TO_LG,
applicationSubmission: mockApplicationSubmission,
government: mockGovernment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@ import {
BaseServiceException,
ServiceValidationException,
} from '../../../../../libs/common/src/exceptions/base.exception';
import { generateCANCApplicationHtml } from '../../../../../templates/emails/cancelled';
import {
generateSUBGNoReviewGovernmentTemplateEmail,
generateSUBGTurApplicantHtml,
} from '../../../../../templates/emails/submitted-to-alc';
import { generateSUBGCoveApplicantHtml } from '../../../../../templates/emails/submitted-to-alc/cove-applicant.template';
import {
generateSUBGApplicantHtml,
generateSUBGGovernmentHtml,
} from '../../../../../templates/emails/submitted-to-lfng';
import { template as cancApplicationTemplate } from '../../../../../templates/emails/cancelled/application.template';
import { template as subgNoReviewGovernmentTemplate } from '../../../../../templates/emails/submitted-to-alc/no-review-government.template';
import { template as subgTurApplicantTemplate } from '../../../../../templates/emails/submitted-to-alc/tur-applicant.template';
import { template as subgCoveApplicantTemplate } from '../../../../../templates/emails/submitted-to-alc/cove-applicant.template';
import { template as subgApplicantTemplate } from '../../../../../templates/emails/submitted-to-lfng/applicant.template';
import { template as subgGovernmentTemplate } from '../../../../../templates/emails/submitted-to-lfng/government.template';
import { SUBMISSION_STATUS } from '../../alcs/application/application-submission-status/submission-status.dto';
import { ApplicationService } from '../../alcs/application/application.service';
import { PARENT_TYPE } from '../../alcs/card/card-subtask/card-subtask.dto';
Expand Down Expand Up @@ -224,7 +220,7 @@ export class ApplicationSubmissionController {
application.status.statusTypeCode !== SUBMISSION_STATUS.IN_PROGRESS
) {
await this.statusEmailService.sendApplicationStatusEmail({
generateStatusHtml: generateCANCApplicationHtml,
template: cancApplicationTemplate,
status: SUBMISSION_STATUS.CANCELLED,
applicationSubmission: application,
government: submissionGovernment,
Expand Down Expand Up @@ -291,7 +287,7 @@ export class ApplicationSubmissionController {
if (matchingType.requiresGovernmentReview) {
if (primaryContact) {
await this.statusEmailService.sendApplicationStatusEmail({
generateStatusHtml: generateSUBGApplicantHtml,
template: subgApplicantTemplate,
status: SUBMISSION_STATUS.SUBMITTED_TO_LG,
applicationSubmission: validatedSubmission,
government: submissionGovernment,
Expand All @@ -303,7 +299,7 @@ export class ApplicationSubmissionController {

if (submissionGovernment) {
await this.statusEmailService.sendApplicationStatusEmail({
generateStatusHtml: generateSUBGGovernmentHtml,
template: subgGovernmentTemplate,
status: SUBMISSION_STATUS.SUBMITTED_TO_LG,
applicationSubmission: validatedSubmission,
government: submissionGovernment,
Expand All @@ -326,13 +322,13 @@ export class ApplicationSubmissionController {
matchingType.code === APPLICATION_SUBMISSION_TYPES.TURP ||
matchingType.code === APPLICATION_SUBMISSION_TYPES.COVE
) {
const generateTemplateFunction =
const template =
matchingType.code === APPLICATION_SUBMISSION_TYPES.TURP
? generateSUBGTurApplicantHtml
: generateSUBGCoveApplicantHtml;
? subgTurApplicantTemplate
: subgCoveApplicantTemplate;

await this.statusEmailService.sendApplicationStatusEmail({
generateStatusHtml: generateTemplateFunction,
template: template,
status: SUBMISSION_STATUS.SUBMITTED_TO_ALC,
applicationSubmission: validatedSubmission,
government: submissionGovernment,
Expand All @@ -344,7 +340,7 @@ export class ApplicationSubmissionController {

if (submissionGovernment) {
await this.statusEmailService.sendApplicationStatusEmail({
generateStatusHtml: generateSUBGNoReviewGovernmentTemplateEmail,
template: subgNoReviewGovernmentTemplate,
status: SUBMISSION_STATUS.SUBMITTED_TO_ALC,
applicationSubmission: validatedSubmission,
government: submissionGovernment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BaseServiceException } from '@app/common/exceptions/base.exception';
import { BadRequestException, Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { generateSUBMNoiGovernmentHtml } from '../../../../../templates/emails/submitted-to-alc/noi-government.template';
import { template } from '../../../../../templates/emails/submitted-to-alc/noi-government.template';
import { PARENT_TYPE } from '../../alcs/card/card-subtask/card-subtask.dto';
import { LocalGovernmentService } from '../../alcs/local-government/local-government.service';
import { NOI_SUBMISSION_STATUS } from '../../alcs/notice-of-intent/notice-of-intent-submission-status/notice-of-intent-status.dto';
Expand Down Expand Up @@ -250,7 +250,7 @@ export class NoticeOfIntentSubmissionDraftService {

if (submissionGovernment) {
await this.statusEmailService.sendNoticeOfIntentStatusEmail({
generateStatusHtml: generateSUBMNoiGovernmentHtml,
template,
status: NOI_SUBMISSION_STATUS.SUBMITTED_TO_ALC,
noticeOfIntentSubmission: savedDraft,
government: submissionGovernment,
Expand Down
Loading

0 comments on commit cfea455

Please sign in to comment.