diff --git a/src/app/modules/submission/multirespondent-submission/multirespondent-submission.service.ts b/src/app/modules/submission/multirespondent-submission/multirespondent-submission.service.ts index a172cb2c11..37ff4909a6 100644 --- a/src/app/modules/submission/multirespondent-submission/multirespondent-submission.service.ts +++ b/src/app/modules/submission/multirespondent-submission/multirespondent-submission.service.ts @@ -240,6 +240,11 @@ const sendMrfOutcomeEmails = ({ return okAsync(true) } + const formQuestionAnswers = getQuestionTitleAnswerString({ + formFields: form.form_fields, + responses, + }) + if (isApproval) { return MailService.sendMrfApprovalEmail({ emails: destinationEmails, @@ -247,6 +252,7 @@ const sendMrfOutcomeEmails = ({ formTitle: form.title, responseId: submissionId, isRejected, + formQuestionAnswers, }).orElse((error) => { logger.error({ message: 'Failed to send approval email', @@ -265,10 +271,7 @@ const sendMrfOutcomeEmails = ({ formId: form._id, formTitle: form.title, responseId: submissionId, - formQuestionAnswers: getQuestionTitleAnswerString({ - formFields: form.form_fields, - responses, - }), + formQuestionAnswers, }).orElse((error) => { logger.error({ message: 'Failed to send workflow completion email', diff --git a/src/app/services/mail/mail.service.ts b/src/app/services/mail/mail.service.ts index d44f7ec4fa..96c2bd7a87 100644 --- a/src/app/services/mail/mail.service.ts +++ b/src/app/services/mail/mail.service.ts @@ -33,11 +33,9 @@ import { getAdminEmails, } from '../../modules/form/form.utils' import { formatAsPercentage } from '../../utils/formatters' -import MrfApprovalOutcomeEmail, { - WorkflowOutcome, -} from '../../views/templates/MrfApprovalOutcomeEmail' import MrfWorkflowCompletionEmail, { QuestionAnswer, + WorkflowOutcome, } from '../../views/templates/MrfWorkflowCompletionEmail' import MrfWorkflowEmail, { WorkflowEmailData, @@ -1138,12 +1136,14 @@ export class MailService { formTitle, responseId, isRejected, + formQuestionAnswers, }: { emails: string[] formId: string formTitle: string responseId: string isRejected: boolean + formQuestionAnswers: QuestionAnswer[] }) => { const outcome = isRejected ? WorkflowOutcome.NOT_APPROVED @@ -1152,9 +1152,10 @@ export class MailService { formTitle, responseId: responseId.toString(), outcome, + formQuestionAnswers, } - const html = render(MrfApprovalOutcomeEmail(htmlData)) + const html = render(MrfWorkflowCompletionEmail(htmlData)) const mail: MailOptions = { to: emails, diff --git a/src/app/views/templates/MrfApprovalOutcomeEmail.tsx b/src/app/views/templates/MrfApprovalOutcomeEmail.tsx deleted file mode 100644 index 5ec35f4a43..0000000000 --- a/src/app/views/templates/MrfApprovalOutcomeEmail.tsx +++ /dev/null @@ -1,90 +0,0 @@ -import { - Body, - Column, - Container, - Head, - Heading, - Hr, - Html, - Img, - Row, - Text, -} from '@react-email/components' -import { FORMSG_LOGO_URL } from '../../constants/formsg-logo' - -import { - headingStyle, - innerContainerStyle, - outerContainerStyle, - textStyle, -} from './styles' - -export enum WorkflowOutcome { - APPROVED = 'Approved', - NOT_APPROVED = 'Not approved' -} - -export type WorkflowOutcomeEmailData = { - formTitle: string - responseId: string - outcome: WorkflowOutcome -} - -export const MrfApprovalOutcomeEmail = ({ - // Defaults are provided only for testing purposes in react-email-preview. - outcome = WorkflowOutcome.APPROVED, - formTitle = 'Test form title', - responseId = '64303c45828035f732088a41' -}: WorkflowOutcomeEmailData): JSX.Element => { - return ( - -
-