Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Change undefined to null in confirmationEmailSchema #2438

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading