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

Check person identifiers in iga when verifying

Displays a warning if the identifier the sponsor wants to verify is
already assigned to someone in the IGA, or if the backend could not
contact the IGA to check.
parent d0ba7877
No related branches found
No related tags found
1 merge request!286UiO: Sjekk om fødselsnummer/passnummer er i bruk i IGA
Pipeline #119267 passed
...@@ -52,7 +52,11 @@ ...@@ -52,7 +52,11 @@
"consentName": "Consent type", "consentName": "Consent type",
"roleInfoHead": "Roles and periods", "roleInfoHead": "Roles and periods",
"roleInfoTableText": "Guest roles", "roleInfoTableText": "Guest roles",
"roleInfoBody": "You can only change roles that you have given." "roleInfoBody": "You can only change roles that you have given.",
"identityCheck": {
"failure": "<strong>Warning</strong>: Unable to check if person already exists in IGA.",
"text": "<strong>Warning</strong>: <1>matches</1> already has this ID registerered to them. Please stop if this is not the same person."
}
}, },
"guest": { "guest": {
"headerText": "Add new role and period.", "headerText": "Add new role and period.",
......
...@@ -52,7 +52,11 @@ ...@@ -52,7 +52,11 @@
"consentName": "Samtykketype", "consentName": "Samtykketype",
"roleInfoHead": "Roller og perioder", "roleInfoHead": "Roller og perioder",
"roleInfoBody": "Du kan endre på tidsperioden, men kun på gjesteroller som du er vert for.", "roleInfoBody": "Du kan endre på tidsperioden, men kun på gjesteroller som du er vert for.",
"roleInfoTableText": "Gjesteroller" "roleInfoTableText": "Gjesteroller",
"identityCheck": {
"failure": "<strong>Advarsel</strong>: Kunne ikke sjekke IGA om personen allerede er registrert.",
"text": "<strong>Advarsel</strong>: <1>matches</1> har allerede denne ID-en registrert på seg i IGA. Stop dersom dette ikke er samme person."
}
}, },
"guest": { "guest": {
"headerText": "Legg til ny rolle og periode", "headerText": "Legg til ny rolle og periode",
......
...@@ -52,7 +52,11 @@ ...@@ -52,7 +52,11 @@
"consentName": "Samtykketype", "consentName": "Samtykketype",
"roleInfoTableText": "Gjesteroller", "roleInfoTableText": "Gjesteroller",
"roleInfoHead": "Roller og periodar", "roleInfoHead": "Roller og periodar",
"roleInfoBody": "Du kan endre på tidsperioden, men berre på gjesteroller som du er vert for." "roleInfoBody": "Du kan endre på tidsperioden, men berre på gjesteroller som du er vert for.",
"identityCheck": {
"failure": "<strong>Advarsel</strong>: Kunne ikkje sjekke IGA om personen allerede er registrert.",
"text": "<strong>Advarsel</strong>: <1>matches</1> har allerede denne ID-en registrert på seg i IGA. Stop dersom dette ikkje er samme person."
}
}, },
"guest": { "guest": {
"headerText": "Legg til ny rolle og periode", "headerText": "Legg til ny rolle og periode",
......
import { Box, Button, TableRow, Typography } from '@mui/material' import { Box, Button, TableRow, Typography } from '@mui/material'
import ConfirmDialog from 'components/confirmDialog' import ConfirmDialog from 'components/confirmDialog'
import { Identity } from 'interfaces' import { Identity } from 'interfaces'
import { useState } from 'react' import { useEffect, useState } from 'react'
import { submitJsonOpts } from 'utils' import { fetchJsonOpts, submitJsonOpts } from 'utils'
import CheckIcon from '@mui/icons-material/Check' import CheckIcon from '@mui/icons-material/Check'
import { useTranslation } from 'react-i18next' import { Trans, useTranslation } from 'react-i18next'
import { TableCell } from 'components/table' import { TableCell } from 'components/table'
import { appInst, disableNinVerification } from 'appConfig' import { appInst, disableNinVerification } from 'appConfig'
...@@ -22,6 +22,9 @@ const IdentityLine = ({ ...@@ -22,6 +22,9 @@ const IdentityLine = ({
reloadGuests, reloadGuests,
}: IdentityLineProps) => { }: 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
if (identity == null) {
return <></>
}
const [confirmOpen, setConfirmOpen] = useState(false) const [confirmOpen, setConfirmOpen] = useState(false)
const [t] = useTranslation('common') const [t] = useTranslation('common')
const verifyIdentity = (id: string) => async () => { const verifyIdentity = (id: string) => async () => {
...@@ -30,7 +33,44 @@ const IdentityLine = ({ ...@@ -30,7 +33,44 @@ const IdentityLine = ({
reloadGuests() reloadGuests()
} }
if (identity == null) { const [identityCheckText, setIdentityCheckText] = useState<string | null>(
null
)
const checkIdentity = (id: string) => {
const igaMatch = fetch(`/api/ui/v1/identitycheck/${id}`, fetchJsonOpts())
.then((res) => res.json())
.then((data) =>
data.match ? `${data.match.first} ${data.match.last}` : null
)
.catch(() => 'failure')
return igaMatch
}
const fetchIdentityCheckText = async (id: string) => {
checkIdentity(id).then((idtxt) => setIdentityCheckText(idtxt))
}
const IdentityCheckText = () => {
if (identityCheckText === 'failure') {
return (
<>
<Trans t={t} i18nKey="guestInfo.identityCheck.failure" />
<br />
<br />
</>
)
}
if (identityCheckText) {
return (
<>
<Trans t={t} i18nKey="guestInfo.identityCheck.text">
Warning: {identityCheckText} already exist in IGA with this ID.
</Trans>
<br />
<br />
</>
)
}
return <></> return <></>
} }
const getDialogText = () => { const getDialogText = () => {
...@@ -43,6 +83,12 @@ const IdentityLine = ({ ...@@ -43,6 +83,12 @@ const IdentityLine = ({
return t('confirmationDialog.text.default') return t('confirmationDialog.text.default')
} }
} }
useEffect(() => {
if (confirmOpen && identityCheckText === null) {
fetchIdentityCheckText(identity.id)
}
}, [confirmOpen])
return ( return (
<TableRow> <TableRow>
<TableCell align="left">{text}</TableCell> <TableCell align="left">{text}</TableCell>
...@@ -88,6 +134,7 @@ const IdentityLine = ({ ...@@ -88,6 +134,7 @@ const IdentityLine = ({
setOpen={setConfirmOpen} setOpen={setConfirmOpen}
onConfirm={verifyIdentity(identity.id)} onConfirm={verifyIdentity(identity.id)}
> >
<IdentityCheckText />
{getDialogText()} {getDialogText()}
</ConfirmDialog> </ConfirmDialog>
</Typography> </Typography>
......
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