Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ey 4835 aktivitetsplikt knapp beregning #6611

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions apps/etterlatte-behandling/src/main/kotlin/sak/SakRoutes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -11,21 +11,22 @@ 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'
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
Expand Down Expand Up @@ -55,7 +56,7 @@ function mapToDto(brevdata: IBrevAktivitetsplikt): IBrevAktivitetspliktRequest {
}

export const ValgForInfobrev = () => {
const { oppgave, aktivtetspliktbrevdata } = useAktivitetspliktOppgaveVurdering()
const { oppgave, aktivtetspliktbrevdata, sak } = useAktivitetspliktOppgaveVurdering()
const {
handleSubmit,
watch,
Expand All @@ -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<boolean>(!aktivtetspliktbrevdata)
const brevdata = aktivtetspliktbrevdata

const lagreBrevutfall = (data: IBrevAktivitetsplikt) => {
const brevdatamappedToDo = mapToDto(data)
lagrebrevdata(
Expand All @@ -82,6 +87,10 @@ export const ValgForInfobrev = () => {
)
}

useEffect(() => {
hentSisteIverkSatteBehandling(sak.id)
}, [sak.id])

useEffect(() => {
if (redigeres && !!aktivtetspliktbrevdata) {
reset(mapFromDto(aktivtetspliktbrevdata))
Expand All @@ -106,6 +115,12 @@ export const ValgForInfobrev = () => {
Valg for infobrev
</Heading>
</HStack>
{isSuccess(hentSisteIverksatteBehandlingStatus) && (
<Link href={`/behandling/${hentSisteIverksatteBehandlingStatus.data.id}/beregne`} as="a" target="_blank">
Vis siste Beregning
<ExternalLinkIcon />
</Link>
)}
{redigeres ? (
<form onSubmit={handleSubmit(lagreBrevutfall)}>
<VStack gap="4">
Expand Down
10 changes: 10 additions & 0 deletions apps/etterlatte-saksbehandling-ui/client/src/shared/api/sak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ export const hentSakMedBehandlnger = async (fnr: string): Promise<ApiResponse<Sa
return apiClient.post(`/personer/behandlingerforsak`, { foedselsnummer: fnr })
}

interface SisteIverksatteBehandling {
id: string
}

export const hentSisteIverksatteBehandlingId = async (
sakId: number
): Promise<ApiResponse<SisteIverksatteBehandling>> => {
return apiClient.get(`/sak/${sakId}behandlinger/sisteIverksatte`)
}

export const hentSak = async (sakId: number): Promise<ApiResponse<ISak>> => {
return apiClient.get(`sak/${sakId}`)
}
Expand Down
Loading