Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #292 from navikt/dev
Browse files Browse the repository at this point in the history
Fix: Infomelding dersom manglende jobbprofil, ikke feilmelding
  • Loading branch information
matiasvinjevoll authored Jun 8, 2022
2 parents 8f7c5aa + b70a80b commit e94832e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,24 @@ import { fetchAktorId, fetchCvOgJobbprofil, fetchUnderOppfolging } from '../../.
import { Feilmelding, Laster } from '../../../felles/fetch';
import { ArenaPerson } from '../../../../rest/datatyper/arenaperson';
import { Alert } from '@navikt/ds-react';
import { isNotStartedOrPending, isRejected, isResolved, useAxiosPromise } from '../../../../utils/use-promise';
import {
isNotStartedOrPending,
isRejected,
isResolved,
useAxiosPromise,
UsePromise
} from '../../../../utils/use-promise';
import { UnderOppfolgingData } from '../../../../rest/datatyper/underOppfolgingData';
import { AktorId } from '../../../../rest/datatyper/aktor-id';
import { AxiosError, AxiosResponse } from 'axios';

const harJobbprofilData = (cvOgJobbprofil: UsePromise<AxiosResponse<ArenaPerson>, AxiosError>): boolean => {
return (
cvOgJobbprofil.result != null &&
cvOgJobbprofil.result.data != null &&
cvOgJobbprofil.result.data.jobbprofil != null
);
};

const JobbprofilPanelInnhold = (): React.ReactElement => {
const { fnr } = useAppStore();
Expand Down Expand Up @@ -67,7 +82,11 @@ const JobbprofilPanelInnhold = (): React.ReactElement => {
}
}

if (cvOgJobbprofil.error?.response?.status === 404 || cvOgJobbprofil.result?.status === 204) {
if (
cvOgJobbprofil.error?.response?.status === 404 ||
cvOgJobbprofil.result?.status === 204 ||
!harJobbprofilData(cvOgJobbprofil)
) {
return (
<Alert variant="info" className="alertstripe_intern">
Denne personen har ikke registrert jobbønsker.&nbsp;&nbsp;
Expand All @@ -82,7 +101,7 @@ const JobbprofilPanelInnhold = (): React.ReactElement => {
return <Feilmelding />;
}

if (cvOgJobbprofil.result?.data) {
if (harJobbprofilData(cvOgJobbprofil)) {
const {
sistEndret,
onsketYrke,
Expand All @@ -91,7 +110,7 @@ const JobbprofilPanelInnhold = (): React.ReactElement => {
onsketArbeidstidsordning,
heltidDeltid,
kompetanse
} = cvOgJobbprofil.result.data.jobbprofil;
} = cvOgJobbprofil.result.data.jobbprofil!;
const arbeidssted = onsketArbeidssted.map(sted => sted.stedsnavn);
const yrker = onsketYrke.map(yrke => yrke.tittel);
const ansettelsesform = onsketAnsettelsesform.map(form => form.tittel);
Expand Down
2 changes: 1 addition & 1 deletion src/rest/datatyper/arenaperson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,6 @@ export interface ArenaPerson {
godkjenninger: Godkjenning[];
andreGodkjenninger: AnnenGodkjenning[];
sprak: Sprak[];
jobbprofil: Jobbprofil;
jobbprofil?: Jobbprofil;
fagdokumentasjoner?: Fagdokumentasjon[];
}
2 changes: 1 addition & 1 deletion src/utils/use-promise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const defaultState: NotStartedPromiseState = {
status: Status.NOT_STARTED
};

type UsePromise<R, E extends Error> = PromiseState<R, E> & {
export type UsePromise<R, E extends Error> = PromiseState<R, E> & {
setPromise: Dispatch<SetStateAction<Promise<R> | undefined>>;
};

Expand Down

0 comments on commit e94832e

Please sign in to comment.