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

Reload guest info properly

Instead of forcing a reload of the page, we trigger a new api call in
the background, meaning we don't get a flash when verifying an identity.
parent 12e26c32
No related branches found
No related tags found
1 merge request!170Greg 101 verify identity
Pipeline #101309 passed
...@@ -4,21 +4,20 @@ import { Identity } from 'interfaces' ...@@ -4,21 +4,20 @@ import { Identity } from 'interfaces'
import { useState } from 'react' import { useState } from 'react'
import { submitJsonOpts } from 'utils' import { submitJsonOpts } from 'utils'
import CheckIcon from '@mui/icons-material/Check' import CheckIcon from '@mui/icons-material/Check'
import { useHistory } from 'react-router-dom'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
interface IdentityLineProps { interface IdentityLineProps {
text: string text: string
identity: Identity | null identity: Identity | null
reloadGuest: () => void
} }
const IdentityLine = ({ text, identity }: IdentityLineProps) => { const IdentityLine = ({ text, identity, reloadGuest }: IdentityLineProps) => {
// Make a line with a confirmation button if the identity has not been verified // Make a line with a confirmation button if the identity has not been verified
const [confirmOpen, setConfirmOpen] = useState(false) const [confirmOpen, setConfirmOpen] = useState(false)
const [t] = useTranslation('common') const [t] = useTranslation('common')
const history = useHistory()
const verifyIdentity = (id: string) => async () => { const verifyIdentity = (id: string) => async () => {
await fetch(`/api/ui/v1/identity/${id}`, submitJsonOpts('PATCH', {})) await fetch(`/api/ui/v1/identity/${id}`, submitJsonOpts('PATCH', {}))
history.go(0) reloadGuest()
} }
if (identity == null) { if (identity == null) {
......
...@@ -35,6 +35,7 @@ type GuestInfoProps = { ...@@ -35,6 +35,7 @@ type GuestInfoProps = {
updateEmail: (validEmail: string) => void updateEmail: (validEmail: string) => void
resend: () => void resend: () => void
reloadGuests: () => void reloadGuests: () => void
reloadGuest: () => void
} }
type CancelConfirmationDialogProps = { type CancelConfirmationDialogProps = {
...@@ -84,6 +85,7 @@ export default function GuestInfo({ ...@@ -84,6 +85,7 @@ export default function GuestInfo({
updateEmail, updateEmail,
resend, resend,
reloadGuests, reloadGuests,
reloadGuest,
}: GuestInfoProps) { }: GuestInfoProps) {
const { pid } = useParams<GuestInfoParams>() const { pid } = useParams<GuestInfoParams>()
const [t] = useTranslation(['common']) const [t] = useTranslation(['common'])
...@@ -232,10 +234,12 @@ export default function GuestInfo({ ...@@ -232,10 +234,12 @@ export default function GuestInfo({
<IdentityLine <IdentityLine
text={t('input.nationalIdNumber')} text={t('input.nationalIdNumber')}
identity={guest.fnr} identity={guest.fnr}
reloadGuest={reloadGuest}
/> />
<IdentityLine <IdentityLine
text={t('input.passportNumber')} text={t('input.passportNumber')}
identity={guest.passport} identity={guest.passport}
reloadGuest={reloadGuest}
/> />
<TableRow> <TableRow>
<TableCell align="left">{t('input.mobilePhone')}</TableCell> <TableCell align="left">{t('input.mobilePhone')}</TableCell>
......
...@@ -67,6 +67,7 @@ function GuestRoutes({ reloadGuests }: GuestRoutesProps) { ...@@ -67,6 +67,7 @@ function GuestRoutes({ reloadGuests }: GuestRoutesProps) {
updateEmail={updateEmail} updateEmail={updateEmail}
resend={resend} resend={resend}
reloadGuests={reloadGuests} reloadGuests={reloadGuests}
reloadGuest={reloadGuestInfo}
/> />
</Route> </Route>
</> </>
......
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