Skip to content

Commit

Permalink
feat(upload-sub-doc-email): Add template for upload subsequent docume…
Browse files Browse the repository at this point in the history
…nts CHIP SPA (#878)

* working through email content

* adjust text language

* added missing preview emails

* add email logic for subseq doc

* fix types

* remove unused

* Update ChipSpaCMS.tsx

* remove unused

* Delete CHIP_SPA.tsx

* adjust template

* adjust based on comments

* Update ChipSpaState.tsx

---------

Co-authored-by: Andie Swift <andie.swift5@gmail.com>
  • Loading branch information
jdinh8124 and andieswift authored Dec 3, 2024
1 parent cab225c commit 666cc2f
Show file tree
Hide file tree
Showing 10 changed files with 220 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/libs/email/content/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from "./withdrawRai";
export * from "./withdrawPackage";
export * from "./email-components";
export * from "./respondToRai";
export * from "./upload-subsequent-documents";
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { CommonEmailVariables, Events } from "shared-types";
import { PackageDetails, BasicFooter, Attachments } from "../../email-components";
import { BaseEmailTemplate } from "../../email-templates";
import { styles } from "../../email-styles";
import { Text } from "@react-email/components";

export const ChipSpaCMSEmail = (props: {
variables: Events["UploadSubsequentDocuments"] & CommonEmailVariables;
}) => {
const variables = props.variables;
const previewText = `Action required: review new documents for CHIP SPA ${variables.id} in OneMAC.`;
const heading = `New documents have been submitted for CHIP SPA ${variables.id} in OneMAC.`;
return (
<BaseEmailTemplate
previewText={previewText}
heading={heading}
applicationEndpointUrl={variables.applicationEndpointUrl}
footerContent={<BasicFooter />}
>
<PackageDetails
details={{
"State or territory": variables.territory,
"CHIP SPA Package ID": variables.id,
Summary: variables.additionalInformation,
}}
/>
<Attachments attachments={variables.attachments} />
<Text style={{ ...styles.text.base, marginTop: "16px", fontWeight: "bold" }}>
How to Access:
</Text>
<Text style={{ ...styles.text.base, marginTop: "16px", marginLeft: "16px" }}>
• These documents can be found in OneMAC through this link{" "}
<a href={variables.applicationEndpointUrl} target="_blank">
{variables.applicationEndpointUrl}
</a>
</Text>
<Text style={{ ...styles.text.base, marginTop: "16px", marginLeft: "16px" }}>
• If you are not already logged in, click “Login” at the top of the page and log in using
your Enterprise User Administration (EUA) credentials.
</Text>
<Text style={{ ...styles.text.base, marginTop: "16px", marginLeft: "16px" }}>
• After you logged in, click the submission ID number on the dashboard page to view details.
</Text>
<Text style={{ ...styles.text.base, marginTop: "16px" }}>Thank you.</Text>
</BaseEmailTemplate>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Events } from "shared-types";
import { CommonEmailVariables } from "shared-types";
import { Text } from "@react-email/components";
import {
PackageDetails,
ContactStateLead,
DetailsHeading,
Attachments,
} from "../../email-components";
import { BaseEmailTemplate } from "../../email-templates";
import { styles } from "../../email-styles";

export const ChipSpaStateEmail = (props: {
variables: Events["UploadSubsequentDocuments"] & CommonEmailVariables;
}) => {
const variables = props.variables;
const previewText = `Additional documents submitted for CHIP SPA ${variables.id}`;
const heading = `You’ve successfully submitted the following to CMS reviewers for CHIP SPA ${variables.id}`;

return (
<BaseEmailTemplate
previewText={previewText}
heading={heading}
applicationEndpointUrl={variables.applicationEndpointUrl}
footerContent={<ContactStateLead isChip />}
>
<DetailsHeading />
<PackageDetails
details={{
"State or territory": variables.territory,
Name: variables.submitterName,
"Email Address": variables.submitterEmail,
"CHIP SPA Package ID": variables.id,
Summary: variables.additionalInformation,
}}
/>
<Attachments attachments={variables.attachments} />
<Text style={{ ...styles.text.base, marginTop: "16px" }}>
If you have questions or did not expect this email, please contact your CPOC.
</Text>
<Text style={{ ...styles.text.base, marginTop: "16px" }}>Thank you.</Text>
</BaseEmailTemplate>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { ChipSpaCMSEmail } from "./ChipSpaCMS";
export { ChipSpaStateEmail } from "./ChipSpaState";
30 changes: 30 additions & 0 deletions lib/libs/email/content/upload-subsequent-documents/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Events, Authority, EmailAddresses, CommonEmailVariables } from "shared-types";
import { AuthoritiesWithUserTypesTemplate } from "../..";
import { ChipSpaCMSEmail, ChipSpaStateEmail } from "./emailTemplates";
import { render } from "@react-email/render";

export const uploadSubsequentDocuments: AuthoritiesWithUserTypesTemplate = {
[Authority.CHIP_SPA]: {
cms: async (
variables: Events["UploadSubsequentDocuments"] &
CommonEmailVariables & { emails: EmailAddresses },
) => {
return {
to: variables.emails.chipInbox,
cc: variables.emails.chipCcList,
subject: `Action required: review new documents for ${variables.actionType + variables.id}`,
body: await render(<ChipSpaCMSEmail variables={variables} />),
};
},
state: async (
variables: Events["UploadSubsequentDocuments"] &
CommonEmailVariables & { emails: EmailAddresses },
) => {
return {
to: [`${variables.submitterName} <${variables.submitterEmail}>`],
subject: `Additional documents submitted for ${variables.actionType + variables.id}`,
body: await render(<ChipSpaStateEmail variables={variables} />),
};
},
},
};
41 changes: 41 additions & 0 deletions lib/libs/email/mock-data/upload-subsequent-documents.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
export const emailTemplateValue = {
territory: "CO",
applicationEndpointUrl: "https://mako-dev.cms.gov/",
actionType: "Upload-Subsequent-Documents",
origin: "mako" as const,
requestedDate: Date.now() - 5 * 24 * 60 * 60,
withdrawnDate: Date.now(),
attachments: {
cmsForm179: {
files: [
{
filename: "withdraw-documentation.pdf",
title: "withdraw-documentation",
bucket: "mako-outbox-attachments-635052997545",
key: "b545ea14-6b1b-47c0-a374-743fcba4391f.pdf",
uploadDate: 1728493782785,
},
],
label: "CMS Form 179",
},
spaPages: {
files: [
{
filename: "Addditional Information.pdf",
title: "Addditional Information",
bucket: "mako-outbox-attachments-635052997545",
key: "f581c0ec-cbb2-4875-a384-86c06136f4c4.pdf",
uploadDate: 1728493784252,
},
],
label: "SPA Pages",
},
},
additionalInformation:
"This some additional infornormaiton about the request to withdraw and what makes it important.",
submitterName: "George Harrison",
submitterEmail: "george@example.com",
timestamp: 1723390633663,
event: "upload-subsequent-documents" as const,
id: "CA-10001-0003",
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { ChipSpaCMSEmail } from "lib/libs/email/content/upload-subsequent-documents/emailTemplates/ChipSpaCMS";
import { emailTemplateValue } from "lib/libs/email/mock-data/upload-subsequent-documents";
import * as attachments from "lib/libs/email/mock-data/attachments";

const ChipSpaCMSEmailPreview = () => {
return (
<ChipSpaCMSEmail
variables={{
...emailTemplateValue,
id: "CO-24-1234",
event: "upload-subsequent-documents",
actionType: "Amend",
attachments: {
currentStatePlan: attachments.currentStatePlan,
amendedLanguage: attachments.amendedLanguage,
coverLetter: attachments.coverLetter,
budgetDocuments: attachments.budgetDocuments,
publicNotice: attachments.publicNotice,
tribalConsultation: attachments.tribalConsultation,
other: attachments.other,
},
}}
/>
);
};

export default ChipSpaCMSEmailPreview;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { emailTemplateValue } from "lib/libs/email/mock-data/upload-subsequent-documents";
import { ChipSpaStateEmail } from "lib/libs/email/content/upload-subsequent-documents/emailTemplates";
import * as attachments from "lib/libs/email/mock-data/attachments";
const ChipSpaStateEmailPreview = () => {
return (
<ChipSpaStateEmail
variables={{
...emailTemplateValue,
id: "CO-24-1234",
event: "upload-subsequent-documents",
actionType: "Amend",
attachments: {
currentStatePlan: attachments.currentStatePlan,
amendedLanguage: attachments.amendedLanguage,
coverLetter: attachments.coverLetter,
budgetDocuments: attachments.budgetDocuments,
publicNotice: attachments.publicNotice,
tribalConsultation: attachments.tribalConsultation,
other: attachments.other,
},
}}
/>
);
};

export default ChipSpaStateEmailPreview;
1 change: 1 addition & 0 deletions lib/packages/shared-types/events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ export type Events = {
TempExtension: z.infer<typeof temporaryExtension.schema>;
NewAppKSubmission: z.infer<typeof appk.schema>;
RespondToRai: z.infer<typeof respondToRai.schema>;
UploadSubsequentDocuments: z.infer<typeof uploadSubsequentDocuments.schema>;
WithdrawPackage: z.infer<typeof withdrawPackage.schema>;
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { z } from "zod";
import { attachmentArraySchemaOptional } from "../attachments";

export const baseSchema = z.object({
event: z
.literal("upload-subsequent-documents")
.default("upload-subsequent-documents"),
event: z.literal("upload-subsequent-documents").default("upload-subsequent-documents"),
additionalInformation: z.string().max(4000).default(null),
attachments: z.record(
z.string(),
Expand Down

0 comments on commit 666cc2f

Please sign in to comment.