Skip to content

Commit

Permalink
fix: Change undefined to null in confirmationEmailSchema (#2438)
Browse files Browse the repository at this point in the history
* fix: Change undefined to null in confirmationEmailSchema

* fix: Don't setup email reminder events if a session is submitted
  • Loading branch information
DafyddLlyr authored Nov 17, 2023
1 parent 4e80624 commit 44a5be8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion api.planx.uk/modules/saveAndReturn/service/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ const sendSingleApplicationEmail = async ({
emailReplyToId: team.notifyPersonalisation.emailReplyToId,
};
const firstSave = !session.hasUserSaved;
if (firstSave) await setupEmailEventTriggers(sessionId);
if (firstSave && !session.submittedAt)
await setupEmailEventTriggers(sessionId);
return await sendEmail(template, email, config);
} catch (error) {
throw Error((error as Error).message);
Expand All @@ -98,6 +99,7 @@ const validateSingleSessionRequest = async (
id
data
created_at
submitted_at
has_user_saved
flow {
slug
Expand Down Expand Up @@ -139,6 +141,7 @@ interface SessionDetails {
projectType: string;
id: string;
expiryDate: string;
submittedAt: string | null;
}

/**
Expand All @@ -162,6 +165,7 @@ const getSessionDetails = async (
id: session.id,
expiryDate: calculateExpiryDate(session.created_at),
hasUserSaved: session.has_user_saved,
submittedAt: session.submitted_at,
};
};

Expand Down
1 change: 1 addition & 0 deletions api.planx.uk/modules/sendEmail/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ describe("Send Email endpoint", () => {
payload: {
sessionId: "123",
email: TEST_EMAIL,
lockedAt: null,
},
};
await supertest(app)
Expand Down
2 changes: 1 addition & 1 deletion api.planx.uk/modules/sendEmail/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const confirmationEmailSchema = z.object({
body: z.object({
payload: z.object({
sessionId: z.string(),
lockedAt: z.string().optional(),
lockedAt: z.string().or(z.null()),
email: z.string().email(),
}),
}),
Expand Down

0 comments on commit 44a5be8

Please sign in to comment.