From bc1854fb5dc1a090590a59e80415c52257f2bbc4 Mon Sep 17 00:00:00 2001 From: Joar Aurdal Date: Tue, 15 Oct 2024 15:28:21 +0200 Subject: [PATCH] =?UTF-8?q?Putt=20loader=20og=20feilh=C3=A5ndtering=20inni?= =?UTF-8?q?=20modal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../analyse/AnalyserStillingModal.tsx | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/stilling/stilling/analyse/AnalyserStillingModal.tsx b/src/stilling/stilling/analyse/AnalyserStillingModal.tsx index c09dfeb9..5b7e37e6 100644 --- a/src/stilling/stilling/analyse/AnalyserStillingModal.tsx +++ b/src/stilling/stilling/analyse/AnalyserStillingModal.tsx @@ -1,4 +1,4 @@ -import { BodyShort, Label, Loader, Modal } from '@navikt/ds-react'; +import { BodyShort, Label, Loader, Modal, Alert } from '@navikt/ds-react'; import css from './AnalyserStillingModal.module.css'; import { hentTittelFraStilling } from 'felles/domene/stilling/Stilling'; import { useStillingsanalyse } from '../../../api/stillings-api/stillingsanalyse'; @@ -19,7 +19,11 @@ const AnalyserStillingModal: React.FC = ({ vis, onClose, /*@ts-ignore: TODO: stilling og AdDataState brukes om hverandre, må ryddes opp, for eksempel ved at hentTittel tar inn parameterene som er */ const stillingstittel = hentTittelFraStilling(stilling); - const { stillingsanalyse, isLoading: isLoadingAnalyse } = useStillingsanalyse( + const { + stillingsanalyse, + isLoading: isLoadingAnalyse, + error, + } = useStillingsanalyse( { stillingsId: stillingsId || '', stillingstype: stillingsinfo?.stillingskategori || 'Stilling', @@ -29,18 +33,6 @@ const AnalyserStillingModal: React.FC = ({ vis, onClose, vis ); - if (isLoadingAnalyse) { - return ; - } - - /*if (isErrorStilling || isErrorAnalyse) { - return ( - - Klarte ikke å laste inn stillingen eller analysere stillingen. - - ); - }*/ - return ( = ({ vis, onClose, heading: 'Analyser stilling', }} > - {stilling && stillingsanalyse && vis && ( +
- + {isLoadingAnalyse && ( +
+ +
+ )} + + {error && ( + + Klarte ikke å analysere stillingen. + + )} + + {!isLoadingAnalyse && !error && stilling && stillingsanalyse && (
@@ -74,9 +78,9 @@ const AnalyserStillingModal: React.FC = ({ vis, onClose, {stillingsanalyse.tittelBegrunnelse}
-
+ )}
- )} +
); };