diff --git a/frontend/public/locales/en/common.json b/frontend/public/locales/en/common.json index 03651e5a766cffbb016ebb577e450984a61b9d62..d577a248de0da775fe2d24f0f0ca8782075b01a4 100644 --- a/frontend/public/locales/en/common.json +++ b/frontend/public/locales/en/common.json @@ -102,7 +102,8 @@ "expiring_other": "Expiring in {{count}} days", "expiring_one": "Expiring in {{count}} day", "waitingForGuest": "Waiting for guest", - "waitingForSponsor": "Needs confirmation" + "waitingForSponsor": "Needs confirmation", + "invitationExpired": "Invitation expired" }, "details": "Details", "nationalIdNumber": "National ID number", @@ -141,7 +142,7 @@ "verify": "Verify", "backToFrontPage": "Go to front page", "cancelInvitation": "Cancel", - "resendInvitation": "Send", + "resendInvitation": "Resend invitation", "ok": "OK", "finishRegistration": "Finish registration" }, diff --git a/frontend/public/locales/nb/common.json b/frontend/public/locales/nb/common.json index d446cc3fc551d031e73f0ee4f7266b255879a2a1..c1c20c7e7076f72f2ab58eea16c2654d72e06835 100644 --- a/frontend/public/locales/nb/common.json +++ b/frontend/public/locales/nb/common.json @@ -102,7 +102,8 @@ "expiring_other": "Utløper om {{count}} dager", "expiring_one": "Utløper om {{count}} dag", "waitingForGuest": "Venter på gjest", - "waitingForSponsor": "Trenger godkjenning" + "waitingForSponsor": "Trenger godkjenning", + "invitationExpired": "Invitasjon utløpt" }, "details": "Detaljer", "nationalIdNumber": "Fødselsnummer/D-nummer", @@ -140,7 +141,7 @@ "cancel": "Avbryt", "verify": "Bekreft", "backToFrontPage": "Tilbake til forsiden", - "resendInvitation": "Send", + "resendInvitation": "Send ny invitasjon", "cancelInvitation": "Kanseller", "ok": "OK", "finishRegistration": "Fullfør registrering" diff --git a/frontend/public/locales/nn/common.json b/frontend/public/locales/nn/common.json index b24dee1a10c420ace8909af2ee2b862d11ab55a0..fb646e25286cfe016c7553a388c5f9320bee3c73 100644 --- a/frontend/public/locales/nn/common.json +++ b/frontend/public/locales/nn/common.json @@ -102,7 +102,8 @@ "expiring_other": "Utløper om {{count}} dagar", "expiring_one": "Utløper om {{count}} dag", "waitingForGuest": "Venter på gjest", - "waitingForSponsor": "Trenger godkjenning" + "waitingForSponsor": "Trenger godkjenning", + "invitationExpired": "Invitasjon utløpt" }, "details": "Detaljer", "nationalIdNumber": "Fødselsnummer/D-nummer", @@ -140,7 +141,7 @@ "cancel": "Avbryt", "verify": "Bekreft", "backToFrontPage": "Tilbake til forsida", - "resendInvitation": "Send", + "resendInvitation": "Send ny invitasjon", "cancelInvitation": "Kanseller", "ok": "OK", "finishRegistration": "Fullfør registrering" diff --git a/frontend/src/hooks/useGuest/index.tsx b/frontend/src/hooks/useGuest/index.tsx index e8051a49fff8709747b64a63490fdc09e90c37c6..418e0b0e45ac0d67a5c0629f3911139069efc1a5 100644 --- a/frontend/src/hooks/useGuest/index.tsx +++ b/frontend/src/hooks/useGuest/index.tsx @@ -1,4 +1,4 @@ -import { FetchedRole, Guest } from 'interfaces' +import { FetchedGuest, FetchedRole, Guest } from 'interfaces' import { useEffect, useState } from 'react' import { parseRole, parseIdentity } from 'utils' @@ -16,27 +16,29 @@ const useGuest = (pid: string) => { registered: false, verified: false, roles: [], + invitation_status: '', }) const getPerson = async (id: string) => { try { const response = await fetch(`/api/ui/v1/person/${id}`) - const rjson = await response.json() + const guest: FetchedGuest = await response.json() if (response.ok) { setGuest({ - pid: rjson.pid, - first: rjson.first, - last: rjson.last, - email: rjson.email, - mobile: rjson.mobile, - fnr: parseIdentity(rjson.fnr), - passport: parseIdentity(rjson.passport), - feide_id: rjson.feide_id, - active: rjson.active, - registered: rjson.registered, - verified: rjson.verified, - roles: rjson.roles.map((role: FetchedRole) => parseRole(role)), + pid: guest.pid, + first: guest.first, + last: guest.last, + email: guest.email, + mobile: guest.mobile, + fnr: parseIdentity(guest.fnr), + passport: parseIdentity(guest.passport), + feide_id: guest.feide_id, + active: guest.active, + registered: guest.registered, + verified: guest.verified, + invitation_status: guest.invitation_status, + roles: guest.roles.map((role: FetchedRole) => parseRole(role)), }) } } catch (error) { diff --git a/frontend/src/hooks/useGuests/index.tsx b/frontend/src/hooks/useGuests/index.tsx index bd074843789b56a57ff0696be36e4cc13693b0a4..d69df315c5cc22c94ac88e6edf542f0bd76a5bf0 100644 --- a/frontend/src/hooks/useGuests/index.tsx +++ b/frontend/src/hooks/useGuests/index.tsx @@ -21,9 +21,10 @@ const useGuests = () => { passport: parseIdentity(person.passport), feide_id: person.feide_id, active: person.active, - roles: person.roles.map((role) => parseRole(role)), registered: person.registered, verified: person.verified, + invitation_status: person.invitation_status, + roles: person.roles.map((role) => parseRole(role)), }) ) ) diff --git a/frontend/src/interfaces/index.ts b/frontend/src/interfaces/index.ts index d339026c40aba1aaaee1e9422f97070b72b4f352..558d8b5f69025d9fd9dde40028a9ac0faafda750 100644 --- a/frontend/src/interfaces/index.ts +++ b/frontend/src/interfaces/index.ts @@ -10,6 +10,7 @@ export type Guest = { active: boolean registered: boolean verified: boolean + invitation_status: string roles: Role[] } @@ -39,6 +40,7 @@ export interface FetchedGuest { active: boolean registered: boolean verified: boolean + invitation_status: string roles: FetchedRole[] } diff --git a/frontend/src/routes/sponsor/frontpage/index.tsx b/frontend/src/routes/sponsor/frontpage/index.tsx index f74754b38bf163b8bacbfb5f1c675832047beedc..d489fc4915e792cb5c5172caebb3e90bf9e2146d 100644 --- a/frontend/src/routes/sponsor/frontpage/index.tsx +++ b/frontend/src/routes/sponsor/frontpage/index.tsx @@ -91,6 +91,9 @@ const Status = ({ person, role }: StatusProps) => { if (!person.registered) { status = 'waitingForGuest' + if (person.invitation_status !== 'active') { + status = 'invitationExpired' + } } else if (person.registered && !person.verified) { status = 'waitingForSponsor' } else if (person.registered && person.verified) { @@ -128,6 +131,12 @@ const Status = ({ person, role }: StatusProps) => { {t('statusText.waitingForSponsor')} </TableCell> ) + case 'invitationExpired': + return ( + <TableCell sx={{ color: 'error.main' }} align="left"> + {t('statusText.invitationExpired')} + </TableCell> + ) case 'expiring': return ( <TableCell sx={{ color: 'blue' }} align="left"> diff --git a/frontend/src/routes/sponsor/guest/guestInfo/index.tsx b/frontend/src/routes/sponsor/guest/guestInfo/index.tsx index a0771f211e4a88b072fd65b39617346909366788..c691d1145ed4ce6d481d84e314b9927538fa1f97 100644 --- a/frontend/src/routes/sponsor/guest/guestInfo/index.tsx +++ b/frontend/src/routes/sponsor/guest/guestInfo/index.tsx @@ -96,7 +96,7 @@ export default function GuestInfo({ const { pid } = useParams<GuestInfoParams>() const [t] = useTranslation(['common']) const history = useHistory() - const [confirmationDialogOpen, setConfirmationDialogOpen] = useState(false) + const [confirmCancelDialogOpen, setConfirmCancelDialogOpen] = useState(false) const [emailUpdateError, setEmailUpdateError] = useState<ServerErrorReportData>() @@ -176,7 +176,7 @@ export default function GuestInfo({ const onSubmit = handleSubmit(submit) const handleCancel = () => { - setConfirmationDialogOpen(true) + setConfirmCancelDialogOpen(true) } const cancelInvitation = () => { @@ -206,7 +206,7 @@ export default function GuestInfo({ } const handleDialogClose = (ok: boolean) => { - setConfirmationDialogOpen(false) + setConfirmCancelDialogOpen(false) if (ok) { cancelInvitation() } @@ -253,13 +253,7 @@ export default function GuestInfo({ <TableRow> <TableCell align="left">{t('input.email')}</TableCell> <TableCell align="left"> - <Box - sx={{ - display: 'flex', - flexDirection: { xs: 'column', md: 'row' }, - justifyContent: 'flex-start', - }} - > + <Box> <TextField InputLabelProps={{ shrink: true }} id="email" @@ -276,31 +270,17 @@ export default function GuestInfo({ {!guest.registered && ( <Box sx={{ - display: 'flex', - flexDirection: 'row', - justifyContent: { - xs: 'flex-start', - md: 'flex-end', - }, + display: 'block', + marginTop: '0.5rem', }} > - <Button - color="secondary" - sx={{ - maxHeight: '2.3rem', - marginLeft: { xs: '0rem', md: '1rem' }, - marginTop: { xs: '0.3rem', md: '0rem' }, - }} - onClick={resend} - > + <Button color="secondary" onClick={resend}> {t('button.resendInvitation')} </Button> <Button color="secondary" sx={{ - maxHeight: '2.3rem', marginLeft: '0.5rem', - marginTop: { xs: '0.3rem', md: '0rem' }, }} onClick={handleCancel} > @@ -310,7 +290,7 @@ export default function GuestInfo({ )} </Box> <CancelConfirmationDialog - open={confirmationDialogOpen} + open={confirmCancelDialogOpen} onClose={handleDialogClose} /> </TableCell>