diff --git a/frontend/app/routes/protected/person-case/primary-docs.tsx b/frontend/app/routes/protected/person-case/primary-docs.tsx index c2d0224e..2460f972 100644 --- a/frontend/app/routes/protected/person-case/primary-docs.tsx +++ b/frontend/app/routes/protected/person-case/primary-docs.tsx @@ -61,6 +61,14 @@ export function meta({ data }: Route.MetaArgs) { return [{ title: data.documentTitle }]; } +function toDateString(year: number, month: number, day: number): string { + try { + return toISODateString(year, month, day); + } catch { + return ''; + } +} + export async function action({ context, request }: Route.ActionArgs) { requireAuth(context.session, new URL(request.url), ['user']); @@ -218,12 +226,12 @@ export async function action({ context, request }: Route.ActionArgs) { const dateOfBirthYear = Number(formData.get('dateOfBirthYear')); const dateOfBirthMonth = Number(formData.get('dateOfBirthMonth')); const dateOfBirthDay = Number(formData.get('dateOfBirthDay')); - const dateOfBirth = toISODateString(dateOfBirthYear, dateOfBirthMonth, dateOfBirthDay); + const dateOfBirth = toDateString(dateOfBirthYear, dateOfBirthMonth, dateOfBirthDay); const citizenshipDateYear = Number(formData.get('citizenshipDateYear')); const citizenshipDateMonth = Number(formData.get('citizenshipDateMonth')); const citizenshipDateDay = Number(formData.get('citizenshipDateDay')); - const citizenshipDate = toISODateString(citizenshipDateYear, citizenshipDateMonth, citizenshipDateDay); + const citizenshipDate = toDateString(citizenshipDateYear, citizenshipDateMonth, citizenshipDateDay); const input = { currentStatusInCanada: String(formData.get('currentStatusInCanada')), diff --git a/frontend/app/utils/date-utils.ts b/frontend/app/utils/date-utils.ts index c892346f..471d803a 100644 --- a/frontend/app/utils/date-utils.ts +++ b/frontend/app/utils/date-utils.ts @@ -241,8 +241,6 @@ export function getStartOfDayInTimezone(timezone: string, date?: number | string * @returns An ISO 8601 date string in the format "YYYY-MM-DD". */ export function toISODateString(year: number, month: number, day: number): string { - if (isNaN(year) || isNaN(month) || isNaN(day)) return ''; - if (!dateExists(year, month - 1, day)) return ''; return formatISODate(`${year}-${month}-${day}`); }