Skip to content
Snippets Groups Projects
Commit 5502e3ee authored by Tore.Brede's avatar Tore.Brede
Browse files

Merge branch 'GREG-220_fix_crash_on_missing_role_start' into 'master'

GREG-220: Fixing crash on missing role start date in frontend

See merge request !296
parents 81571983 e737ba5b
No related branches found
No related tags found
1 merge request!296GREG-220: Fixing crash on missing role start date in frontend
Pipeline #119820 failed
...@@ -48,7 +48,7 @@ export type Role = { ...@@ -48,7 +48,7 @@ export type Role = {
name_en: string name_en: string
ou_nb: string ou_nb: string
ou_en: string ou_en: string
start_date: Date start_date?: Date
end_date: Date end_date: Date
max_days: number max_days: number
contact_person_unit: string | null contact_person_unit: string | null
......
...@@ -61,8 +61,11 @@ test('Button state correct on load', async () => { ...@@ -61,8 +61,11 @@ test('Button state correct on load', async () => {
</Router> </Router>
) )
await waitFor(() => { await waitFor(
expect(screen.getByText('button.save')).toBeDisabled() () => {
expect(screen.getByText('sponsor.endNow')).toBeEnabled() expect(screen.getByText('button.save')).toBeDisabled()
}) expect(screen.getByText('sponsor.endNow')).toBeEnabled()
},
{ timeout: 5000 }
)
}) })
...@@ -181,7 +181,10 @@ export default function GuestRoleInfo({ ...@@ -181,7 +181,10 @@ export default function GuestRoleInfo({
setRole(roleInfo) setRole(roleInfo)
// Set values of date fields to current dates if role exists // Set values of date fields to current dates if role exists
setValue('end_date', roleInfo.end_date) 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(() => { useEffect(() => {
......
...@@ -145,7 +145,7 @@ export function parseRole(role: FetchedRole): Role { ...@@ -145,7 +145,7 @@ export function parseRole(role: FetchedRole): Role {
name_en: role.name_en, name_en: role.name_en,
ou_nb: role.ou_nb, ou_nb: role.ou_nb,
ou_en: role.ou_en, 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), end_date: parseISO(role.end_date),
max_days: role.max_days, max_days: role.max_days,
contact_person_unit: role.contact_person_unit, contact_person_unit: role.contact_person_unit,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment