From 1c0c5cd1c732089a6178c2f8da1be0695d3defa9 Mon Sep 17 00:00:00 2001 From: Hanne Olsen Date: Wed, 20 Nov 2024 11:17:46 +0100 Subject: [PATCH] =?UTF-8?q?Legger=20p=C3=A5=20visning=20av=20feilmelding?= =?UTF-8?q?=20p=C3=A5=20utsending=20av=20brev?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../H\303\270yremeny/SendMelding/SendMelding.tsx" | 8 ++++---- .../SendMelding/SendMeldingContext.tsx" | 11 ++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git "a/src/frontend/komponenter/Fagsak/H\303\270yremeny/SendMelding/SendMelding.tsx" "b/src/frontend/komponenter/Fagsak/H\303\270yremeny/SendMelding/SendMelding.tsx" index b8a76495..a1587ebd 100644 --- "a/src/frontend/komponenter/Fagsak/H\303\270yremeny/SendMelding/SendMelding.tsx" +++ "b/src/frontend/komponenter/Fagsak/H\303\270yremeny/SendMelding/SendMelding.tsx" @@ -1,6 +1,6 @@ import * as React from 'react'; -import { BodyShort, Button, Heading, Select, Textarea } from '@navikt/ds-react'; +import { BodyShort, Button, Fieldset, Heading, Select, Textarea } from '@navikt/ds-react'; import ForhåndsvisBrev from './ForhåndsvisBrev/ForhåndsvisBrev'; import { useSendMelding } from './SendMeldingContext'; @@ -24,7 +24,7 @@ interface IProps { } const SendMelding: React.FC = ({ fagsak, behandling }) => { - const { maler, skjema, senderInn, sendBrev } = useSendMelding(); + const { maler, skjema, senderInn, sendBrev, feilmelding } = useSendMelding(); const { behandlingILesemodus } = useBehandling(); const erLesevisning = !!behandlingILesemodus; @@ -36,7 +36,7 @@ const SendMelding: React.FC = ({ fagsak, behandling }) => { const kanSende = skjema.felter.maltype.verdi !== '' && skjema.felter.fritekst.verdi !== ''; return ( -
+
{behandling.manuelleBrevmottakere.length ? ( <> @@ -109,7 +109,7 @@ const SendMelding: React.FC = ({ fagsak, behandling }) => { {kanSende && } -
+ ); }; diff --git "a/src/frontend/komponenter/Fagsak/H\303\270yremeny/SendMelding/SendMeldingContext.tsx" "b/src/frontend/komponenter/Fagsak/H\303\270yremeny/SendMelding/SendMeldingContext.tsx" index 716bf250..712c7f80 100644 --- "a/src/frontend/komponenter/Fagsak/H\303\270yremeny/SendMelding/SendMeldingContext.tsx" +++ "b/src/frontend/komponenter/Fagsak/H\303\270yremeny/SendMelding/SendMeldingContext.tsx" @@ -19,7 +19,11 @@ import { DokumentMal } from '../../../../kodeverk'; import { BrevPayload } from '../../../../typer/api'; import { IBehandling } from '../../../../typer/behandling'; import { IFagsak } from '../../../../typer/fagsak'; -import { erFeltetEmpty, validerTekstFeltMaksLengde } from '../../../../utils'; +import { + erFeltetEmpty, + hentFrontendFeilmelding, + validerTekstFeltMaksLengde, +} from '../../../../utils'; import { sider } from '../../../Felleskomponenter/Venstremeny/sider'; interface Mottaker { @@ -50,6 +54,7 @@ interface IProps { const [SendMeldingProvider, useSendMelding] = createUseContext(({ behandling, fagsak }: IProps) => { const [senderInn, settSenderInn] = React.useState(false); + const [feilmelding, settFeilmelding] = React.useState(); const { hentBehandlingMedBehandlingId } = useBehandling(); const { bestillBrev } = useDokumentApi(); const navigate = useNavigate(); @@ -104,6 +109,7 @@ const [SendMeldingProvider, useSendMelding] = createUseContext(({ behandling, fa settSenderInn(true); bestillBrev(hentBrevdata()).then((respons: Ressurs) => { settSenderInn(false); + settFeilmelding(undefined); if (respons.status === RessursStatus.SUKSESS) { nullstillSkjema(); hentBehandlingMedBehandlingId(behandling.behandlingId).then(() => { @@ -111,6 +117,8 @@ const [SendMeldingProvider, useSendMelding] = createUseContext(({ behandling, fa `/fagsystem/${fagsak.fagsystem}/fagsak/${fagsak.eksternFagsakId}/behandling/${behandling.eksternBrukId}/${sider.VERGE.href}` ); }); + } else { + settFeilmelding(hentFrontendFeilmelding(respons)); } }); } else { @@ -126,6 +134,7 @@ const [SendMeldingProvider, useSendMelding] = createUseContext(({ behandling, fa kanSendeSkjema, senderInn, sendBrev, + feilmelding, }; });