Skip to content

Commit

Permalink
Merge pull request #1121 from bcgov/feature/ALCS-1121
Browse files Browse the repository at this point in the history
Add Email Template for Covenants
  • Loading branch information
dhaselhan authored Oct 31, 2023
2 parents dfcf8d5 + 773aa39 commit 97bcf2f
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ServiceValidationException } from '../../../../../libs/common/src/excep
import { generateCANCApplicationHtml } from '../../../../../templates/emails/cancelled';
import {
generateSUBGTurApplicantHtml,
generateSUBGTurGovernmentHtml,
generateSUBGNoReviewGovernmentTemplateEmail,
} from '../../../../../templates/emails/submitted-to-alc';
import {
generateSUBGApplicantHtml,
Expand Down Expand Up @@ -452,7 +452,7 @@ describe('ApplicationSubmissionController', () => {
expect(
mockStatusEmailService.sendApplicationStatusEmail,
).toHaveBeenCalledWith({
generateStatusHtml: generateSUBGTurGovernmentHtml,
generateStatusHtml: generateSUBGNoReviewGovernmentTemplateEmail,
status: SUBMISSION_STATUS.SUBMITTED_TO_ALC,
applicationSubmission: mockApplicationSubmission,
government: mockGovernment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ import {
import { generateCANCApplicationHtml } from '../../../../../templates/emails/cancelled';
import {
generateSUBGTurApplicantHtml,
generateSUBGTurGovernmentHtml,
generateSUBGNoReviewGovernmentTemplateEmail,
} from '../../../../../templates/emails/submitted-to-alc';
import { generateSUBGCoveApplicantHtml } from '../../../../../templates/emails/submitted-to-alc/cove-applicant.template';
import {
generateSUBGApplicantHtml,
generateSUBGGovernmentHtml,
Expand All @@ -31,6 +32,7 @@ import { LocalGovernmentService } from '../../alcs/local-government/local-govern
import { PortalAuthGuard } from '../../common/authorization/portal-auth-guard.service';
import { StatusEmailService } from '../../providers/email/status-email.service';
import { User } from '../../user/user.entity';
import { APPLICATION_SUBMISSION_TYPES } from '../pdf-generation/generate-submission-document.service';
import {
ApplicationSubmissionValidatorService,
ValidatedApplicationSubmission,
Expand Down Expand Up @@ -326,30 +328,40 @@ export class ApplicationSubmissionController {
);

if (primaryContact) {
await this.statusEmailService.sendApplicationStatusEmail({
generateStatusHtml: generateSUBGTurApplicantHtml,
status: SUBMISSION_STATUS.SUBMITTED_TO_ALC,
applicationSubmission: validatedSubmission,
government: submissionGovernment,
parentType: PARENT_TYPE.APPLICATION,
primaryContact,
});
}
if (
matchingType.code === APPLICATION_SUBMISSION_TYPES.TURP ||
matchingType.code === APPLICATION_SUBMISSION_TYPES.COVE
) {
const generateTemplateFunction =
matchingType.code === APPLICATION_SUBMISSION_TYPES.TURP
? generateSUBGTurApplicantHtml
: generateSUBGCoveApplicantHtml;

if (submissionGovernment) {
await this.statusEmailService.sendApplicationStatusEmail({
generateStatusHtml: generateSUBGTurGovernmentHtml,
status: SUBMISSION_STATUS.SUBMITTED_TO_ALC,
applicationSubmission: validatedSubmission,
government: submissionGovernment,
parentType: PARENT_TYPE.APPLICATION,
});
}
await this.statusEmailService.sendApplicationStatusEmail({
generateStatusHtml: generateTemplateFunction,
status: SUBMISSION_STATUS.SUBMITTED_TO_ALC,
applicationSubmission: validatedSubmission,
government: submissionGovernment,
parentType: PARENT_TYPE.APPLICATION,
primaryContact,
});
}

return await this.applicationSubmissionService.updateStatus(
validatedSubmission,
SUBMISSION_STATUS.SUBMITTED_TO_ALC,
);
if (submissionGovernment) {
await this.statusEmailService.sendApplicationStatusEmail({
generateStatusHtml: generateSUBGNoReviewGovernmentTemplateEmail,
status: SUBMISSION_STATUS.SUBMITTED_TO_ALC,
applicationSubmission: validatedSubmission,
government: submissionGovernment,
parentType: PARENT_TYPE.APPLICATION,
});
}

return await this.applicationSubmissionService.updateStatus(
validatedSubmission,
SUBMISSION_STATUS.SUBMITTED_TO_ALC,
);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { MJMLParseResults } from 'mjml-core';
import { StatusUpdateEmail } from '../../../apps/alcs/src/providers/email/status-email.service';
import { EmailTemplateService } from '../../../libs/common/src/email-template-service/email-template.service';
import { header, footer, notificationOnly, portalButton } from '../partials';

const template = `<mjml>
<mj-head>
<mj-style>
.line-height div {
line-height: 24px !important;
}
.align-left {
float: left !important;
}
</mj-style>
</mj-head>
<mj-body width="600px">
${header}
<mj-section background-color="white" padding="48px 0px 48px 0px">
<mj-column width="600px" css-class='line-height'>
<mj-text font-size='16px'>
This email is to acknowledge that the Agricultural Land Commission (ALC) is in receipt of the above noted <b>{{ childType }}</b> application. Please refer to the ALC Application ID in all future correspondence with this office. A copy of this application has been forwarded to the <b>{{ governmentName }}</b> for information purposes.
</mj-text>
<mj-text font-size='16px'>
There is no application fee associated with registering a Restrictive Covenant.
</mj-text>
<mj-text font-size='16px'>
If you are an agent acting on behalf of the applicant(s) / landowner(s), it is your responsibility to advise them of this, and any future, correspondence.
</mj-text>
<mj-text font-size='16px'>
Please log into the ALC Portal for further updates on the application as it progresses.
</mj-text>
${notificationOnly}
</mj-column>
</mj-section>
${portalButton}
${footer}
</mj-body>
</mjml>
`;

export const generateSUBGCoveApplicantHtml = (
data: StatusUpdateEmail,
): MJMLParseResults => {
return new EmailTemplateService().generateEmailBase(template, data);
};
2 changes: 1 addition & 1 deletion services/templates/emails/submitted-to-alc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export * from './application.template';
export * from './noi-applicant.template';
export * from './noi-government.template';
export * from './tur-applicant.template';
export * from './tur-government.template';
export * from './no-review-government.template';
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const template = `<mjml>
</mjml>
`;

export const generateSUBGTurGovernmentHtml = (
export const generateSUBGNoReviewGovernmentTemplateEmail = (
data: StatusUpdateEmail,
): MJMLParseResults => {
return new EmailTemplateService().generateEmailBase(template, data);
Expand Down

0 comments on commit 97bcf2f

Please sign in to comment.