diff --git a/frontend/src/routes/sponsor/guest/guestRoleInfo/index.tsx b/frontend/src/routes/sponsor/guest/guestRoleInfo/index.tsx index 8d5fe0bc8832b073f0e014812f25fa9c0c8adaff..f8b43d3c77597227799339f992fac44604bebc69 100644 --- a/frontend/src/routes/sponsor/guest/guestRoleInfo/index.tsx +++ b/frontend/src/routes/sponsor/guest/guestRoleInfo/index.tsx @@ -30,9 +30,14 @@ import useOus from '../../../../hooks/useOus' interface GuestRoleInfoProps { guest: Guest reloadGuest: () => void + reloadGuests: () => void } -const endPeriodPost = (id: string, data: { end_date: Date }) => { +const endPeriodPost = ( + id: string, + data: { end_date: Date }, + reloadGuests: () => void +) => { const payload = { end_date: format(data.end_date as Date, 'yyyy-MM-dd'), } @@ -48,6 +53,7 @@ const endPeriodPost = (id: string, data: { end_date: Date }) => { .then((result) => { if (result !== null) { console.log('result', result) + reloadGuests() } }) .catch((error) => { @@ -107,6 +113,7 @@ const TableContainer = styled(TableContainerMui)({ export default function GuestRoleInfo({ guest, reloadGuest, + reloadGuests, }: GuestRoleInfoProps) { const { pid, id } = useParams<GuestRoleInfoParams>() const { ous } = useOus() @@ -145,7 +152,7 @@ export default function GuestRoleInfo({ setBadEndDate(true) } else { role.end_date = newEndDate - endPeriodPost(role_id, { end_date: newEndDate }) + endPeriodPost(role_id, { end_date: newEndDate }, reloadGuests) // Go back to guest overview page navigate(`/sponsor/guest/${guest.pid}`, { state: { @@ -192,6 +199,7 @@ export default function GuestRoleInfo({ console.log('result', result) } // Reload the guest so that the information on the overview page is updated + reloadGuests() reloadGuest() // A submit does not clear the dirty state, so resetting values in the form // to the values just submitted to clear the dirty-flag diff --git a/frontend/src/routes/sponsor/guest/index.tsx b/frontend/src/routes/sponsor/guest/index.tsx index 3ecccbaa2597696e0af1d261fd23fd61db886cab..41ecd2ff2bdf2f85afece8ca720039f89f4aad2c 100644 --- a/frontend/src/routes/sponsor/guest/index.tsx +++ b/frontend/src/routes/sponsor/guest/index.tsx @@ -66,7 +66,11 @@ function GuestRoutes({ reloadGuests }: GuestRoutesProps) { <Route path="/roles/:id" element={ - <GuestRoleInfo guest={guestInfo} reloadGuest={reloadGuestInfo} /> + <GuestRoleInfo + guest={guestInfo} + reloadGuest={reloadGuestInfo} + reloadGuests={reloadGuests} + /> } /> <Route