Skip to content

Commit

Permalink
Merge pull request #3645 from navikt/vis-om-eps-har-sak
Browse files Browse the repository at this point in the history
link til eps sak dersom dem har en eksisterende sak
  • Loading branch information
RamziAbuQassim authored Aug 26, 2024
2 parents d07eec7 + 4ac8871 commit c45906d
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 13 deletions.
7 changes: 7 additions & 0 deletions src/api/sakApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,10 @@ export const bekreftFnrEndring = async (arg: {
},
});
};

export const hentEpsSaksIderForDenneSak = async (sakId: string): Promise<ApiClientResult<string[]>> => {
return apiClient<string[]>({
url: `/saker/${sakId}/epsSak`,
method: 'GET',
});
};
1 change: 1 addition & 0 deletions src/assets/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from '@navikt/aksel-icons';

const iconWidth = '30px';

interface Props {
width?: string | number;
className?: string;
Expand Down
49 changes: 46 additions & 3 deletions src/components/personlinje/Personlinje.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Link } from 'react-router-dom';

import { ErrorCode } from '~src/api/apiClient';
import { fetchPerson } from '~src/api/personApi';
import { hentEpsSaksIderForDenneSak } from '~src/api/sakApi';
import { KjønnUkjent } from '~src/assets/Icons';
import { pipe } from '~src/lib/fp';
import { useApiCall } from '~src/lib/hooks';
Expand All @@ -14,6 +15,7 @@ import { Person, SivilstandTyper, Sivilstand as ISivilstand } from '~src/types/P
import { showName, formatFnr } from '~src/utils/person/personUtils';

import { PersonAdvarsel } from '../personadvarsel/PersonAdvarsel';
import { createToast, ToastType, useToast } from '../toast/Toast';

import messages from './personlinje-nb';
import styles from './personlinje.module.less';
Expand Down Expand Up @@ -59,7 +61,7 @@ const Personlinje = (props: { søker: Person; sakInfo: { sakId: string; saksnumm
{props.søker.sivilstand && (
<span className={styles.sivilstandAndSeperator}>
<Separator />
<Sivilstand sivilstand={props.søker.sivilstand} />
<Sivilstand sakId={props.sakInfo.sakId} sivilstand={props.søker.sivilstand} />
</span>
)}
</div>
Expand All @@ -68,17 +70,47 @@ const Personlinje = (props: { søker: Person; sakInfo: { sakId: string; saksnumm
);
};

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

const { insert } = useToast();
const [status, hentPerson] = useApiCall(fetchPerson);
const [hentEpsSaksIderStatus, hentEpsSaksIder] = useApiCall(hentEpsSaksIderForDenneSak);

useEffect(() => {
if (props.sivilstand.relatertVedSivilstand) {
hentPerson(props.sivilstand.relatertVedSivilstand);
}
}, []);

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

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 (
<span className={styles.sivilstand}>
<BodyShort as="span">
Expand All @@ -102,7 +134,18 @@ const Sivilstand = (props: { sivilstand: ISivilstand }) => {
(eps) => (
<span className={styles.epsInformasjon}>
<KjønnUkjent size="24px" />
<BodyShort>{showName(eps.navn)}</BodyShort>
{RemoteData.isSuccess(hentEpsSaksIderStatus) && hentEpsSaksIderStatus.value.length === 1 ? (
<Link
target="_blank"
to={Routes.saksoversiktValgtSak.createURL({
sakId: hentEpsSaksIderStatus.value[0],
})}
>
<BodyShort>{showName(eps.navn)}</BodyShort>
</Link>
) : (
<BodyShort>{showName(eps.navn)}</BodyShort>
)}
<CopyButton
copyText={eps.fnr}
activeText={formatMessage('ariaLabel.kopierteFnr')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,18 @@ const BehandlingssamendragTableRow = ({
setContextMenuVariables({
pos: { x: e.pageX, y: e.pageY },
toggled: true,
onMenuClick: () => {
return handleOnClick((sak) =>
window.open(Routes.saksoversiktValgtSak.createURL({ sakId: sak.id }), '_blank'),
);
},
onMenuClick: () =>
handleOnClick((sak) => {
window.open(Routes.saksoversiktValgtSak.createURL({ sakId: sak.id }));
}),
});
}}
>
<Button
variant="tertiary"
onClick={() => {
return handleOnClick((sak) =>
navigate(Routes.saksoversiktValgtSak.createURL({ sakId: sak.id })),
);
}}
onClick={() =>
handleOnClick((sak) => navigate(Routes.saksoversiktValgtSak.createURL({ sakId: sak.id })))
}
loading={RemoteData.isPending(hentSakStatus)}
>
{formatMessage('sak.seSak')}
Expand Down

0 comments on commit c45906d

Please sign in to comment.