Skip to content

Commit

Permalink
feat(te/appk): Adding initial temp extension emails and appk for b's …
Browse files Browse the repository at this point in the history
…and c's (#1049)

* Update with tempExt and appks

* Addd 1915b appks

* Update

* Update

* Update
  • Loading branch information
benjaminpaige authored Jan 22, 2025
1 parent 891ebb6 commit 64d8339
Show file tree
Hide file tree
Showing 16 changed files with 87 additions and 43 deletions.
17 changes: 12 additions & 5 deletions lib/lambda/processEmailsHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import { Authority } from "shared-types";
import { SIMPLE_ID, WITHDRAW_RAI_ITEM_B, WITHDRAW_RAI_ITEM_C } from "mocks";
const nms = "new-medicaid-submission";
const ncs = "new-chip-submission";
const tempExtension = "temp-extension";
const tempExtension = "temporary-extension";
const withdrawPackage = "withdraw-package";
const contractingInitial = "contracting-initial";
const capitatedInitial = "capitated-initial";
const withdrawRai = "withdraw-rai";
const respondToRai = "respond-to-rai";
const appk = "app-k";

describe("process emails Handler", () => {
it.each([
Expand Down Expand Up @@ -131,9 +132,9 @@ describe("process emails Handler", () => {
SIMPLE_ID,
],
[
`should send an email for ${withdrawPackage} with ${Authority["1915c"]}`,
`should send an email for ${appk} with ${Authority["1915c"]}`,
Authority["1915c"],
withdrawPackage,
appk,
SIMPLE_ID,
],
[
Expand Down Expand Up @@ -179,9 +180,15 @@ describe("process emails Handler", () => {
SIMPLE_ID,
],
[
`should send an email for ${capitatedInitial} with ${Authority["1915c"]}`,
`should send an email for ${appk} with ${Authority["1915c"]}`,
Authority["1915c"],
capitatedInitial,
appk,
SIMPLE_ID,
],
[
`should send an email for ${appk} with ${Authority["1915b"]}`,
Authority["1915b"],
appk,
SIMPLE_ID,
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { BaseEmailTemplate } from "../../email-templates";
import { formatDate } from "shared-utils";

type AppKEmailProps = Events["NewAppKSubmission"] & CommonEmailVariables;
type AppKEmailProps = Events["AppKSubmission"] & CommonEmailVariables;

// 1915c - app K
export const AppKCMSEmail = ({ variables }: { variables: AppKEmailProps }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { BaseEmailTemplate } from "../../email-templates";
import { styles } from "../../email-styles";

export const AppKStateEmail = (props: {
variables: Events["NewAppKSubmission"] & CommonEmailVariables;
variables: Events["AppKSubmission"] & CommonEmailVariables;
}) => {
const variables = props.variables;
const previewText = `Appendix K Amendment Submitted`;
Expand Down
33 changes: 26 additions & 7 deletions lib/libs/email/content/newSubmission/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,31 +61,50 @@ export const newSubmission: AuthoritiesWithUserTypesTemplate = {
variables:
| (Events["CapitatedInitial"] & CommonEmailVariables & { emails: EmailAddresses })
| (Events["ContractingInitial"] & CommonEmailVariables & { emails: EmailAddresses })
| (Events["CapitatedRenewal"] & CommonEmailVariables & { emails: EmailAddresses }),
| (Events["CapitatedRenewal"] & CommonEmailVariables & { emails: EmailAddresses })
| (Events["ContractingRenewal"] & CommonEmailVariables & { emails: EmailAddresses })
| (Events["CapitatedAmendment"] & CommonEmailVariables & { emails: EmailAddresses })
| (Events["ContractingAmendment"] & CommonEmailVariables & { emails: EmailAddresses })
| (Events["AppKSubmission"] & CommonEmailVariables & { emails: EmailAddresses }),
) => {
return {
to: variables.emails.osgEmail,
subject: `${variables.authority} ${variables.id} Submitted`,
body: await render(<Waiver1915bCMSEmail variables={variables} />),
body: await render(
variables.event === "app-k" ? (
<AppKCMSEmail variables={variables} />
) : (
<Waiver1915bCMSEmail variables={variables} />
),
),
};
},
state: async (
variables:
| (Events["CapitatedInitial"] & CommonEmailVariables & { emails: EmailAddresses })
| (Events["ContractingInitial"] & CommonEmailVariables & { emails: EmailAddresses })
| (Events["CapitatedRenewal"] & CommonEmailVariables & { emails: EmailAddresses }),
| (Events["CapitatedRenewal"] & CommonEmailVariables & { emails: EmailAddresses })
| (Events["ContractingRenewal"] & CommonEmailVariables & { emails: EmailAddresses })
| (Events["CapitatedAmendment"] & CommonEmailVariables & { emails: EmailAddresses })
| (Events["ContractingAmendment"] & CommonEmailVariables & { emails: EmailAddresses })
| (Events["AppKSubmission"] & CommonEmailVariables & { emails: EmailAddresses }),
) => {
return {
to: [`${variables.submitterName} <${variables.submitterEmail}>`],
subject: `Your ${variables.authority} ${variables.id} has been submitted to CMS`,
body: await render(<Waiver1915bStateEmail variables={variables} />),
body: await render(
variables.event === "app-k" ? (
<AppKCMSEmail variables={variables} />
) : (
<Waiver1915bStateEmail variables={variables} />
),
),
};
},
},

[Authority["1915c"]]: {
cms: async (
variables: Events["NewAppKSubmission"] & CommonEmailVariables & { emails: EmailAddresses },
variables: Events["AppKSubmission"] & CommonEmailVariables & { emails: EmailAddresses },
) => {
return {
to: variables.emails.osgEmail,
Expand All @@ -94,7 +113,7 @@ export const newSubmission: AuthoritiesWithUserTypesTemplate = {
};
},
state: async (
variables: Events["NewAppKSubmission"] & CommonEmailVariables & { emails: EmailAddresses },
variables: Events["AppKSubmission"] & CommonEmailVariables & { emails: EmailAddresses },
) => {
return {
to: [`${variables.submitterName} <${variables.submitterEmail}>`],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {
import { BaseEmailTemplate } from "../../email-templates";
import { formatNinetyDaysDate } from "shared-utils";

export const TempExtCMSEmail = (props: {
variables: Events["TempExtension"] & CommonEmailVariables;
}) => {
type TempExtCMSEmailProps = Events["TemporaryExtension"] & CommonEmailVariables;

export const TempExtCMSEmail = (props: { variables: TempExtCMSEmailProps }) => {
const variables = props.variables;
const previewText = `Temporary Extension ${variables.id} Submitted`;
const heading = `The Submission Portal received a ${variables.authority} Temporary Extension Submission:`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { formatNinetyDaysDate } from "shared-utils";
import { CommonEmailVariables } from "shared-types";
import { CommonEmailVariables, Events } from "shared-types";
import { PackageDetails, MailboxNotice, FollowUpNotice, Attachments } from "../../email-components";

import { BaseEmailTemplate } from "../../email-templates";

export const TempExtStateEmail = (props: { variables: any & CommonEmailVariables }) => {
type TempExtStateEmailProps = Events["TemporaryExtension"] & CommonEmailVariables;

export const TempExtStateEmail = (props: { variables: TempExtStateEmailProps }) => {
const variables = props.variables;
const previewText = `Temporary Extension ${variables.id} Submitted`;
const heading =
Expand Down
4 changes: 2 additions & 2 deletions lib/libs/email/content/tempExtension/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { TempExtCMSEmail, TempExtStateEmail } from "./emailTemplates";

export const tempExtention: UserTypeOnlyTemplate = {
cms: async (
variables: Events["TempExtension"] & CommonEmailVariables & { emails: EmailAddresses },
variables: Events["TemporaryExtension"] & CommonEmailVariables & { emails: EmailAddresses },
) => {
return {
to: variables.emails.osgEmail,
Expand All @@ -15,7 +15,7 @@ export const tempExtention: UserTypeOnlyTemplate = {
};
},
state: async (
variables: Events["TempExtension"] & CommonEmailVariables & { emails: EmailAddresses },
variables: Events["TemporaryExtension"] & CommonEmailVariables & { emails: EmailAddresses },
) => {
return {
to: [`${variables.submitterName} <${variables.submitterEmail}>`],
Expand Down
6 changes: 4 additions & 2 deletions lib/libs/email/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type AuthoritiesWithUserTypesTemplate = {
export type EmailTemplates = {
"new-medicaid-submission": AuthoritiesWithUserTypesTemplate;
"new-chip-submission": AuthoritiesWithUserTypesTemplate;
"temp-extension": UserTypeOnlyTemplate;
"temporary-extension": UserTypeOnlyTemplate;
"withdraw-package": AuthoritiesWithUserTypesTemplate;
"withdraw-rai": AuthoritiesWithUserTypesTemplate;
"contracting-initial": AuthoritiesWithUserTypesTemplate;
Expand All @@ -37,13 +37,14 @@ export type EmailTemplates = {
"contracting-renewal-state": AuthoritiesWithUserTypesTemplate;
"capitated-renewal-state": AuthoritiesWithUserTypesTemplate;
"respond-to-rai": AuthoritiesWithUserTypesTemplate;
"app-k": AuthoritiesWithUserTypesTemplate;
};

// Create a type-safe mapping of email templates
const emailTemplates: EmailTemplates = {
"new-medicaid-submission": EmailContent.newSubmission,
"new-chip-submission": EmailContent.newSubmission,
"temp-extension": EmailContent.tempExtention,
"temporary-extension": EmailContent.tempExtention,
"withdraw-package": EmailContent.withdrawPackage,
"withdraw-rai": EmailContent.withdrawRai,
"contracting-initial": EmailContent.newSubmission,
Expand All @@ -57,6 +58,7 @@ const emailTemplates: EmailTemplates = {
"contracting-renewal-state": EmailContent.newSubmission,
"capitated-renewal-state": EmailContent.newSubmission,
"respond-to-rai": EmailContent.respondToRai,
"app-k": EmailContent.newSubmission,
};

// Create a type-safe lookup function
Expand Down
2 changes: 0 additions & 2 deletions lib/libs/email/mock-data/temp-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ export const emailTemplateValue = {
territory: "MD",
id: "MD-2343.R00.TE09",
waiverNumber: "MD-2343.R00.TE00",
authority: "1915(b)",
actionType: "Extend",
applicationEndpointUrl: "https://mako-dev.cms.gov/",
get timestamp() {
return Date.now() + 5184000000;
Expand Down
25 changes: 25 additions & 0 deletions lib/libs/email/preview/InitialSubmissions/CMS/AppK.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { AppKCMSEmail } from "../../../content/newSubmission/emailTemplates";
import { emailTemplateValue } from "../../../mock-data/new-submission";
import * as attachments from "../../../mock-data/attachments";

const AppKCMSEmailPreview = () => {
return (
<AppKCMSEmail
variables={{
...emailTemplateValue,
event: "app-k",
id: "CO-1234.R21.00",
authority: "1915(c)",
actionType: "Amend",
territory: "CO",
title: "A Perfect Appendix K Amendment Title",
attachments: {
appk: attachments.appk,
other: attachments.other,
},
}}
/>
);
};

export default AppKCMSEmailPreview;
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const TempExtCMSPreview = () => {
<TempExtCMSEmail
variables={{
...emailTemplateValue,
authority: "1915(b)",
actionType: "Extend",
}}
/>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { emailTemplateValue } from "../../../mock-data/temp-extension";

import { TempExtStateEmail } from "../../../content/tempExtension/emailTemplates/TempExtState";

const TempExtStatePreview = () => {
return (
<TempExtStateEmail
variables={{
...emailTemplateValue,
authority: "1915(b)",
actionType: "Extend",
}}
/>
);
Expand Down
14 changes: 0 additions & 14 deletions lib/libs/email/preview/Initial_Submissions/CMS/Temp_Extension.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion lib/libs/email/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ export interface NewSubmissionTemplateProps<T extends keyof Events> {
}

export interface TempExtensionTemplateProps {
variables: Events["TempExtension"] & CommonEmailVariables;
variables: Events["TemporaryExtension"] & CommonEmailVariables;
}
2 changes: 2 additions & 0 deletions lib/packages/shared-types/events/app-k.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ export const schema = baseSchema.extend({
submitterEmail: z.string().email(),
timestamp: z.number(),
});

export type AppKSubmission = z.infer<typeof schema>;
4 changes: 2 additions & 2 deletions lib/packages/shared-types/events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const events = {
export type BaseSchemas = z.infer<typeof newMedicaidSubmission.baseSchema>;

export type Events = {
AppKSubmission: z.infer<typeof appk.schema>;
CapitatedInitial: z.infer<typeof capitatedIntial.schema>;
CapitatedRenewal: z.infer<typeof capitatedRenewal.schema>;
CapitatedAmendment: z.infer<typeof capitatedAmendment.schema>;
Expand All @@ -53,8 +54,7 @@ export type Events = {
ContractingAmendment: z.infer<typeof contractingAmendment.schema>;
NewChipSubmission: z.infer<typeof newChipSubmission.schema>;
NewMedicaidSubmission: z.infer<typeof newMedicaidSubmission.schema>;
TempExtension: z.infer<typeof temporaryExtension.schema>;
NewAppKSubmission: z.infer<typeof appk.schema>;
TemporaryExtension: z.infer<typeof temporaryExtension.schema>;
RespondToRai: z.infer<typeof respondToRai.schema>;
UploadSubsequentDocuments: z.infer<typeof uploadSubsequentDocuments.schema>;
WithdrawPackage: z.infer<typeof withdrawPackage.schema>;
Expand Down

0 comments on commit 64d8339

Please sign in to comment.