From 9ff4770a5ab9272260569d97b3f27eea8fd9072c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Oliver=20S=C3=B8berg?= Date: Fri, 13 Dec 2024 10:24:43 +0100 Subject: [PATCH 1/3] EY-4835 Vis siste beregning i brevvalg aktivitetsplikt --- .../src/main/kotlin/sak/SakRoutes.kt | 13 ++++++++++ .../aktivitetsplikt/brev/ValgForInfobrev.tsx | 24 +++++++++++++++---- .../client/src/shared/api/sak.ts | 10 ++++++++ 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/apps/etterlatte-behandling/src/main/kotlin/sak/SakRoutes.kt b/apps/etterlatte-behandling/src/main/kotlin/sak/SakRoutes.kt index 7bbe8c5c32b..ee1d6ec854f 100644 --- a/apps/etterlatte-behandling/src/main/kotlin/sak/SakRoutes.kt +++ b/apps/etterlatte-behandling/src/main/kotlin/sak/SakRoutes.kt @@ -210,6 +210,19 @@ internal fun Route.sakWebRoutes( ) } + get("/behandlinger/sisteIverksatte") { + logger.info("Henter siste iverksatte behandling for $sakId") + + val sisteIverksatteBehandling = + inTransaction { + behandlingService + .hentSisteIverksatte(sakId) + ?.let { SisteIverksatteBehandling(it.id) } + } ?: throw GenerellIkkeFunnetException() + + call.respond(sisteIverksatteBehandling) + } + post("/oppdater-ident") { kunSaksbehandlerMedSkrivetilgang { saksbehandler -> val hendelseId = diff --git a/apps/etterlatte-saksbehandling-ui/client/src/components/aktivitetsplikt/brev/ValgForInfobrev.tsx b/apps/etterlatte-saksbehandling-ui/client/src/components/aktivitetsplikt/brev/ValgForInfobrev.tsx index 7132c8bfc3e..5f26f53b495 100644 --- a/apps/etterlatte-saksbehandling-ui/client/src/components/aktivitetsplikt/brev/ValgForInfobrev.tsx +++ b/apps/etterlatte-saksbehandling-ui/client/src/components/aktivitetsplikt/brev/ValgForInfobrev.tsx @@ -1,4 +1,4 @@ -import { Alert, BodyShort, Box, Button, Heading, HStack, Radio, Textarea, VStack } from '@navikt/ds-react' +import { Alert, BodyShort, Box, Button, Heading, HStack, Link, Radio, Textarea, VStack } from '@navikt/ds-react' import React, { useEffect, useState } from 'react' import { JaNei, JaNeiRec, mapBooleanToJaNei } from '~shared/types/ISvar' import { useForm } from 'react-hook-form' @@ -11,7 +11,7 @@ import { } from '~shared/api/aktivitetsplikt' import { ControlledRadioGruppe } from '~shared/components/radioGruppe/ControlledRadioGruppe' import { isFailureHandler } from '~shared/api/IsFailureHandler' -import { PencilIcon } from '@navikt/aksel-icons' +import { ExternalLinkIcon, PencilIcon } from '@navikt/aksel-icons' import { Info } from '~components/behandling/soeknadsoversikt/Info' import { useAktivitetspliktOppgaveVurdering } from '~components/aktivitetsplikt/AktivitetspliktOppgaveVurderingRoutes' import { erOppgaveRedigerbar } from '~shared/types/oppgave' @@ -19,13 +19,14 @@ import { useDispatch } from 'react-redux' import { setAktivtetspliktbrevdata, setBrevid } from '~store/reducers/Aktivitetsplikt12mnd' import { useNavigate } from 'react-router' import { AktivitetspliktSteg } from '~components/aktivitetsplikt/stegmeny/AktivitetspliktStegmeny' -import { isPending, mapFailure } from '~shared/api/apiUtils' +import { isPending, isSuccess, mapFailure } from '~shared/api/apiUtils' import { ApiErrorAlert } from '~ErrorBoundary' import { handlinger } from '~components/behandling/handlinger/typer' import { Spraak } from '~shared/types/Brev' import { formaterSpraak } from '~utils/formatering/formatering' import { LoependeUnntakInfo } from '~components/aktivitetsplikt/brev/LoependeUnntakInfo' import { formaterDatoMedTidspunkt } from '~utils/formatering/dato' +import { hentSisteIverksatteBehandlingId } from '~shared/api/sak' interface IBrevAktivitetsplikt { skalSendeBrev: JaNei @@ -55,7 +56,7 @@ function mapToDto(brevdata: IBrevAktivitetsplikt): IBrevAktivitetspliktRequest { } export const ValgForInfobrev = () => { - const { oppgave, aktivtetspliktbrevdata } = useAktivitetspliktOppgaveVurdering() + const { oppgave, aktivtetspliktbrevdata, sak } = useAktivitetspliktOppgaveVurdering() const { handleSubmit, watch, @@ -68,8 +69,12 @@ export const ValgForInfobrev = () => { const dispatch = useDispatch() const [lagrebrevdataStatus, lagrebrevdata, tilbakestillApiResult] = useApiCall(lagreAktivitetspliktBrevdata) + const [hentSisteIverksatteBehandlingStatus, hentSisteIverkSatteBehandling] = useApiCall( + hentSisteIverksatteBehandlingId + ) const [redigeres, setRedigeres] = useState(!aktivtetspliktbrevdata) const brevdata = aktivtetspliktbrevdata + const lagreBrevutfall = (data: IBrevAktivitetsplikt) => { const brevdatamappedToDo = mapToDto(data) lagrebrevdata( @@ -81,6 +86,11 @@ export const ValgForInfobrev = () => { () => {} ) } + //TODO: kanpp for siste beregning her + + useEffect(() => { + hentSisteIverkSatteBehandling(sak.id) + }, [sak.id]) useEffect(() => { if (redigeres && !!aktivtetspliktbrevdata) { @@ -106,6 +116,12 @@ export const ValgForInfobrev = () => { Valg for infobrev + {isSuccess(hentSisteIverksatteBehandlingStatus) && ( + + Vis siste Beregning + + + )} {redigeres ? (
diff --git a/apps/etterlatte-saksbehandling-ui/client/src/shared/api/sak.ts b/apps/etterlatte-saksbehandling-ui/client/src/shared/api/sak.ts index 1ef186b564d..52df8ac85f8 100644 --- a/apps/etterlatte-saksbehandling-ui/client/src/shared/api/sak.ts +++ b/apps/etterlatte-saksbehandling-ui/client/src/shared/api/sak.ts @@ -19,6 +19,16 @@ export const hentSakMedBehandlnger = async (fnr: string): Promise> => { + return apiClient.get(`/sak/${sakId}behandlinger/sisteIverksatte`) +} + export const hentSak = async (sakId: number): Promise> => { return apiClient.get(`sak/${sakId}`) } From a96bf5e312aae2999a62785ae3fa4d81b7eac18c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Oliver=20S=C3=B8berg?= Date: Fri, 13 Dec 2024 10:32:51 +0100 Subject: [PATCH 2/3] Riktig url --- .../src/components/aktivitetsplikt/brev/ValgForInfobrev.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/etterlatte-saksbehandling-ui/client/src/components/aktivitetsplikt/brev/ValgForInfobrev.tsx b/apps/etterlatte-saksbehandling-ui/client/src/components/aktivitetsplikt/brev/ValgForInfobrev.tsx index 5f26f53b495..329380a5d39 100644 --- a/apps/etterlatte-saksbehandling-ui/client/src/components/aktivitetsplikt/brev/ValgForInfobrev.tsx +++ b/apps/etterlatte-saksbehandling-ui/client/src/components/aktivitetsplikt/brev/ValgForInfobrev.tsx @@ -117,7 +117,7 @@ export const ValgForInfobrev = () => { {isSuccess(hentSisteIverksatteBehandlingStatus) && ( - + Vis siste Beregning From e37be27f884093289d499b74de43e6c7e73b355c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Oliver=20S=C3=B8berg?= Date: Fri, 13 Dec 2024 10:33:59 +0100 Subject: [PATCH 3/3] Fjern todo --- .../src/components/aktivitetsplikt/brev/ValgForInfobrev.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/etterlatte-saksbehandling-ui/client/src/components/aktivitetsplikt/brev/ValgForInfobrev.tsx b/apps/etterlatte-saksbehandling-ui/client/src/components/aktivitetsplikt/brev/ValgForInfobrev.tsx index 329380a5d39..201a0c25a0c 100644 --- a/apps/etterlatte-saksbehandling-ui/client/src/components/aktivitetsplikt/brev/ValgForInfobrev.tsx +++ b/apps/etterlatte-saksbehandling-ui/client/src/components/aktivitetsplikt/brev/ValgForInfobrev.tsx @@ -86,7 +86,6 @@ export const ValgForInfobrev = () => { () => {} ) } - //TODO: kanpp for siste beregning her useEffect(() => { hentSisteIverkSatteBehandling(sak.id)