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

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

parent d6b0b899
No related branches found
No related tags found
1 merge request!296GREG-220: Fixing crash on missing role start date in frontend
Pipeline #118856 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
......
...@@ -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