Skip to content

Commit

Permalink
lenker til eps sak selv om eps ikke finnes i pdl
Browse files Browse the repository at this point in the history
  • Loading branch information
RamziAbuQassim committed Aug 26, 2024
1 parent c45906d commit aaa698a
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/personadvarsel/personAdvarsel.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
display: flex;
gap: @spacing-xs;
flex-wrap: wrap;
align-items: center;
}
63 changes: 61 additions & 2 deletions src/components/personlinje/Personlinje.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,78 @@ const Personlinje = (props: { søker: Person; sakInfo: { sakId: string; saksnumm
text={props.sakInfo.saksnummer.toString()}
/>
</span>
{props.søker.sivilstand && (
{props.søker.sivilstand ? (
<span className={styles.sivilstandAndSeperator}>
<Separator />
<Sivilstand sakId={props.sakInfo.sakId} sivilstand={props.søker.sivilstand} />
</span>
) : (
<EpsSakLinkUtenSivilstand sakId={props.sakInfo.sakId} />
)}
</div>
<PersonAdvarsel person={props.søker} />
</div>
);
};

const EpsSakLinkUtenSivilstand = (props: { sakId: string }) => {
const { insert } = useToast();

const [hentEpsSaksIderStatus, hentEpsSaksIder] = useApiCall(hentEpsSaksIderForDenneSak);

useEffect(() => {
hentEpsSaksIder(props.sakId);
}, [props.sakId]);

useEffect(() => {
if (RemoteData.isFailure(hentEpsSaksIderStatus)) {
insert(
createToast({
type: ToastType.ERROR,
duration: 5000,
message: 'En feil skjedde ved sjekk om eps har sak',
}),
);
}

if (RemoteData.isSuccess(hentEpsSaksIderStatus) && hentEpsSaksIderStatus.value.length > 1) {
insert(
createToast({
type: ToastType.INFO,
duration: 5000,
message: 'Saken har flere EPS som har SU-uføre sak',
}),
);
}
}, [hentEpsSaksIderStatus._tag]);

return pipe(
hentEpsSaksIderStatus,
RemoteData.fold(
() => null,
() => <Loader />,
() => null,
(epsSaker) => (
<div>
{epsSaker.length === 1 ? (
<Alert variant="info">
<BodyShort>Saken har EPS registrert fra vedtak, men fant ikke fra PDL</BodyShort>
<Link
target="_blank"
to={Routes.saksoversiktValgtSak.createURL({
sakId: epsSaker[0],
})}
>
<BodyShort>Gå til EPS-sak</BodyShort>
</Link>
</Alert>
) : null}
</div>
),
),
);
};

const Sivilstand = (props: { sakId: string; sivilstand: ISivilstand }) => {
const { formatMessage } = useI18n({ messages });

Expand Down Expand Up @@ -116,7 +176,6 @@ const Sivilstand = (props: { sakId: string; sivilstand: ISivilstand }) => {
<BodyShort as="span">
{formatMessage('label.sivilstand')}: {formatSivilstandType(props.sivilstand.type, formatMessage)}
</BodyShort>

{pipe(
status,
RemoteData.fold(
Expand Down

0 comments on commit aaa698a

Please sign in to comment.