Skip to content

Commit

Permalink
Updated new email submissions and test data
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminpaige committed Oct 22, 2024
1 parent 9c0edc8 commit cb90f1b
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 51 deletions.
Binary file modified bun.lockb
Binary file not shown.
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/lambda/submit/submit.ts → lib/lambda/submit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { response } from "libs/handler-lib";
import { APIGatewayEvent } from "aws-lambda";

import { submissionPayloads } from "./submissionPayloads";
import { produceMessage } from "../../libs/api/kafka";
import { produceMessage } from "libs/api/kafka";
import { BaseSchemas } from "shared-types/events";

export const submit = async (event: APIGatewayEvent) => {
Expand Down
21 changes: 9 additions & 12 deletions lib/libs/email/content/email-components.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as React from "react";
import { Text, Link, Section } from "@react-email/components";
import { Attachment } from "shared-types";

type AttachmentsType = { ["string"]: { files: Attachment[]; label: "string" } };
type AttachmentsType = {
[key: string]: { files?: Attachment[]; label: string };
};

export const LoginInstructions = (props: { appEndpointURL: string }) => {
return (
Expand Down Expand Up @@ -30,14 +31,10 @@ export const LoginInstructions = (props: { appEndpointURL: string }) => {

export const Attachments = (props: { attachments: AttachmentsType }) => {
//check if empty
const areAllAttachmentsEmpty = (attachments: AttachmentsType) => {
let key: keyof typeof attachments;
for (key in attachments) {
if (attachments[key].files.length > 0) {
return false;
}
}
return true;
const areAllAttachmentsEmpty = (attachments: AttachmentsType): boolean => {
return Object.values(attachments).every(
({ files }) => !files || files.length === 0,
);
};

// return if empty
Expand Down Expand Up @@ -73,7 +70,7 @@ export const Attachments = (props: { attachments: AttachmentsType }) => {
props.attachments[key].files,
);
return (
<li key={key + idx}>
<li key={key + String(idx)}>
{title}: {filenames}
</li>
);
Expand All @@ -86,7 +83,7 @@ export const Attachments = (props: { attachments: AttachmentsType }) => {

export const PackageDetails = (props: {
details: { [key: string]: string | null | undefined };
attachments?: AttachmentsType | null;
attachments: AttachmentsType | null;
}) => {
return (
<Section>
Expand Down
47 changes: 20 additions & 27 deletions lib/libs/email/content/new-submission/data.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
export const key = "C0-24-8110";

export const emailTemplateValue = {
id: "PACKAGE ID",
to: "George Harrison <[email protected]>",
id: "C0-24-8110",
territory: "CO",
applicationEndpointUrl: "https://onemac.cms.gov/",
timestamp: 1723390633663,
authority: "AUTHORITY",
seaActionType: "Amend",
actionType: "ACTION TYPE",
origin: "micro",
appkParentId: null,
originalWaiverNumber: null,
additionalInformation: "This bens additional infornormaiton",
authority: "CHIP SPA",
timestamp: 1121234556,
submitterName: "George Harrison",
submitterEmail: "[email protected]",
additionalInformation: "This is additional information",
attachments: {
cmsForm179: {
currentStatePlan: {
files: [
{
filename: "test.pdf",
Expand All @@ -27,7 +21,7 @@ export const emailTemplateValue = {
],
label: "CMS Form 179",
},
spaPages: {
amendedLanguage: {
files: [
{
filename: "test1.pdf",
Expand All @@ -54,19 +48,22 @@ export const emailTemplateValue = {
label: "SPA Pages",
},
coverLetter: {
files: [
{
filename: "cover-leter.pdf",
title: "test",
bucket: "mako-outbox-attachments-635052997545",
key: "f581c0ec-cbb2-4875-a384-86c06136f4c4.pdf",
uploadDate: 1728493784252,
},
],
label: "Cover Letter",
},
tribalEngagement: {
budgetDocuments: {
label: "Document Demonstrating Good-Faith Tribal Engagement",
},
existingStatePlanPages: {
label: "Existing State Plan Page(s)",
},
publicNotice: {
label: "Public Notice",
},
sfq: {
label: "Standard Funding Questions (SFQs)",
label: "Existing State Plan Page(s)",
},
tribalConsultation: {
label: "Tribal Consultation",
Expand All @@ -75,14 +72,10 @@ export const emailTemplateValue = {
label: "Other",
},
},
raiWithdrawEnabled: false,
notificationMetadata: {
submissionDate: 1723420800000,
proposedEffectiveDate: 1725062400000,
},
proposedEffectiveDate: 1725062400000,
};

export const sucessfullRepsonse = {
export const successfulResponse = {
$metadata: {
httpStatusCode: 200,
requestId: "d1e89223-05e6-4aad-9c7a-c93ac045e2ef",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from "react";
import { DateTime } from "luxon";
import { Html, Container } from "@react-email/components";
import { OneMac } from "shared-types";
// import { OneMac } from "shared-types";
import { CommonVariables, formatNinetyDaysDate } from "../../..";
import {
PackageDetails,
Expand All @@ -11,7 +11,8 @@ import {
import { emailTemplateValue } from "../data";

export const AppKStateEmail = (props: {
variables: OneMac & CommonVariables;
variables: // Onemac &&
CommonVariables;
}) => {
const variables = props.variables;
return (
Expand Down Expand Up @@ -56,7 +57,10 @@ export const AppKStateEmail = (props: {
const AppKStateEmailPreview = () => {
return (
<AppKStateEmail
variables={emailTemplateValue as OneMac & CommonVariables}
variables={
emailTemplateValue as // OneMac &
CommonVariables
}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from "react";
import { emailTemplateValue } from "../data";
import { OneMac } from "shared-types";
import { Events } from "shared-types";
import { CommonVariables } from "../../..";
import { Html, Container } from "@react-email/components";
import {
Expand All @@ -10,7 +9,7 @@ import {
} from "../../email-components";

export const ChipSpaCMSEmail = (props: {
variables: OneMac & CommonVariables;
variables: Events["NewChipSubmission"] & CommonVariables;
}) => {
const variables = props.variables;
return (
Expand Down Expand Up @@ -40,7 +39,12 @@ export const ChipSpaCMSEmail = (props: {
const ChipSpaCMSEmailPreview = () => {
return (
<ChipSpaCMSEmail
variables={emailTemplateValue as OneMac & CommonVariables}
variables={{
...emailTemplateValue,
event: "new-chip-submission",
actionType: "Amend",
origin: "mako",
}}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as React from "react";
import { emailTemplateValue } from "../data";
import { OneMac } from "shared-types";
import { Events } from "shared-types";
import { CommonVariables } from "../../..";
import { Html, Container } from "@react-email/components";
import { PackageDetails, ContactStateLead } from "../../email-components";

export const ChipSpaStateEmail = (props: {
variables: OneMac & CommonVariables;
variables: Events["NewChipSubmission"] & CommonVariables;
}) => {
const variables = props.variables;
return (
Expand All @@ -24,6 +24,7 @@ export const ChipSpaStateEmail = (props: {
"CHIP SPA Package ID": variables.id,
Summary: variables.additionalInformation,
}}
attachments={variables.attachments}
/>
<p>
This response confirms the receipt of your CHIP State Plan Amendment
Expand All @@ -40,7 +41,9 @@ export const ChipSpaStateEmail = (props: {
const ChipSpaStateEmailPreview = () => {
return (
<ChipSpaStateEmail
variables={emailTemplateValue as OneMac & CommonVariables}
variables={
emailTemplateValue as Events["NewChipSubmission"] & CommonVariables
}
/>
);
};
Expand Down
2 changes: 1 addition & 1 deletion lib/libs/email/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface CommonVariables {
territory: string;
applicationEndpointUrl: string;
actionType: string;
allStateUsersEmails: string[];
allStateUsersEmails?: string[];
}

export const formatAttachments = (
Expand Down
1 change: 1 addition & 0 deletions lib/packages/shared-types/events/new-chip-submission.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { z } from "zod";

import {
attachmentArraySchema,
attachmentArraySchemaOptional,
Expand Down
1 change: 1 addition & 0 deletions lib/stacks/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export class Email extends cdk.NestedStack {
this,
"ProcessEmailsLambda",
{
functionName: `${project}-${stage}-${stack}-processEmails`,
depsLockFilePath: join(__dirname, "../../bun.lockb"),
entry: join(__dirname, "../lambda/processEmails.ts"),
handler: "handler",
Expand Down

0 comments on commit cb90f1b

Please sign in to comment.