Skip to content
Snippets Groups Projects
Verified Commit 20dd5079 authored by Andreas Ellewsen's avatar Andreas Ellewsen
Browse files

Fix visual bug in role info page date fields

Values of fields now show the current dates of the role after data has
been fetched, instead of the placeholders.
parent 5bc9d890
No related branches found
No related tags found
1 merge request!269Show role comments and use feature flags
Pipeline #113978 passed
......@@ -109,13 +109,6 @@ export default function GuestRoleInfo({ guest }: GuestRoleInfoProps) {
contact_person_unit: null,
comments: null,
})
// Find the role info relevant for this page
const getRoleInfo = () => {
const roleInfo = guest.roles.filter((ro) => ro.id.toString() === id)[0]
if (roleInfo) {
setRole(roleInfo)
}
}
// Prepare min and max date values
const today = new Date()
const todayPlusMaxDays = addDays(role.max_days)(today)
......@@ -154,10 +147,21 @@ export default function GuestRoleInfo({ guest }: GuestRoleInfoProps) {
const {
control,
handleSubmit,
setValue,
formState: { isDirty, isValid },
} = useForm({ mode: 'onChange' })
} = useForm<RoleFormData>({ mode: 'onChange' })
const onSubmit = handleSubmit(submit)
// Find the role info relevant for this page
const getRoleInfo = () => {
const roleInfo = guest.roles.filter((ro) => ro.id.toString() === id)[0]
if (roleInfo) {
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)
}
}
useEffect(() => {
getRoleInfo()
}, [guest])
......
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