diff --git a/frontend/src/interfaces/index.ts b/frontend/src/interfaces/index.ts index 9ebcefd5d2239fb2dd46ae9c47f728f0f8fd56cf..d339026c40aba1aaaee1e9422f97070b72b4f352 100644 --- a/frontend/src/interfaces/index.ts +++ b/frontend/src/interfaces/index.ts @@ -48,7 +48,7 @@ export type Role = { name_en: string ou_nb: string ou_en: string - start_date: Date + start_date?: Date end_date: Date max_days: number contact_person_unit: string | null diff --git a/frontend/src/routes/sponsor/guest/guestRoleInfo/index.test.tsx b/frontend/src/routes/sponsor/guest/guestRoleInfo/index.test.tsx index cd5098c9513ec4c03b6a2907a1efd09b04920887..aca738605e837e47aa7089daf95608dfd257fce0 100644 --- a/frontend/src/routes/sponsor/guest/guestRoleInfo/index.test.tsx +++ b/frontend/src/routes/sponsor/guest/guestRoleInfo/index.test.tsx @@ -61,8 +61,11 @@ test('Button state correct on load', async () => { </Router> ) - await waitFor(() => { - expect(screen.getByText('button.save')).toBeDisabled() - expect(screen.getByText('sponsor.endNow')).toBeEnabled() - }) + await waitFor( + () => { + expect(screen.getByText('button.save')).toBeDisabled() + expect(screen.getByText('sponsor.endNow')).toBeEnabled() + }, + { timeout: 5000 } + ) }) diff --git a/frontend/src/routes/sponsor/guest/guestRoleInfo/index.tsx b/frontend/src/routes/sponsor/guest/guestRoleInfo/index.tsx index b425227ff464c516b81f64840acc696df094faa1..c63c674bc69e229d9097ba21fa0e9e78c1b69fcd 100644 --- a/frontend/src/routes/sponsor/guest/guestRoleInfo/index.tsx +++ b/frontend/src/routes/sponsor/guest/guestRoleInfo/index.tsx @@ -181,7 +181,10 @@ export default function GuestRoleInfo({ setRole(roleInfo) // Set values of date fields to current dates if role exists setValue('end_date', roleInfo.end_date) - setValue('start_date', roleInfo.start_date) + // The start date can be undefined for existing roles that have been imported + if (roleInfo.start_date !== undefined) { + setValue('start_date', roleInfo.start_date) + } } } useEffect(() => { diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts index 746d2a286bac0a624db8fe6f84b04b75ca1e95c8..237976bcfb29d2db9c06a0a2f72aa41ee7bc7aed 100644 --- a/frontend/src/utils/index.ts +++ b/frontend/src/utils/index.ts @@ -145,7 +145,7 @@ export function parseRole(role: FetchedRole): Role { name_en: role.name_en, ou_nb: role.ou_nb, ou_en: role.ou_en, - start_date: parseISO(role.start_date), + start_date: role.start_date == null ? undefined : parseISO(role.start_date), end_date: parseISO(role.end_date), max_days: role.max_days, contact_person_unit: role.contact_person_unit,