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

EY-4798 Vis advarsel hvis det er gjeldende unntak i saken #6474

Merged
merged 5 commits into from
Nov 28, 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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { VurderAktivitet } from '~components/aktivitetsplikt/vurdering/VurderAkt
import { VurderingInfoBrevOgOppsummering } from '~components/aktivitetsplikt/brev/VurderingInfoBrevOgOppsummering'
import { AktivitetspliktOppgaveVurdering } from '~shared/types/Aktivitetsplikt'
import { useAktivitetspliktOppgaveVurderingState } from '~store/reducers/Aktivitetsplikt12mnd'
import { ValgForInfobrev } from '~components/person/aktivitet/vurderingAvAktivitetsplikt/ValgForInfobrev'
import { ValgForInfobrev } from '~components/aktivitetsplikt/brev/ValgForInfobrev'

const AktivitetspliktOppgaveContext = createContext<AktivitetspliktOppgaveVurdering>(
{} as AktivitetspliktOppgaveVurdering
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import RedigerbartBrev from '~components/behandling/brev/RedigerbartBrev'
import { useAktivitetspliktOppgaveVurdering } from '~components/aktivitetsplikt/OppgaveVurderingRoute'
import { InfobrevKnapperad } from '~components/aktivitetsplikt/brev/VurderingInfoBrevOgOppsummering'
import { FerdigstillAktivitetspliktBrevModal } from '~components/aktivitetsplikt/brev/FerdigstillBrevModal'
import { LoependeUnntakInfo } from '~components/aktivitetsplikt/brev/LoependeUnntakInfo'

export function Aktivitetspliktbrev({ brevId }: { brevId: number }) {
const { oppgave, sistEndret } = useAktivitetspliktOppgaveVurdering()
Expand Down Expand Up @@ -63,6 +64,8 @@ export function Aktivitetspliktbrev({ brevId }: { brevId: number }) {
<Box marginInline="0 8">
<Heading size="large">Infobrev aktivitetsplikt</Heading>
</Box>

<LoependeUnntakInfo />
<BrevTittel brevId={brev.id} sakId={brev.sakId} tittel={brev.tittel} kanRedigeres={kanRedigeres} />
<BrevSpraak brev={brev} kanRedigeres={false} />
{kanRedigeres && (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Alert } from '@navikt/ds-react'
import React from 'react'
import { useAktivitetspliktOppgaveVurdering } from '~components/aktivitetsplikt/OppgaveVurderingRoute'
import { IAktivitetspliktVurderingNyDto } from '~shared/types/Aktivitetsplikt'

function loeperUnntakEtterSisteVurdering(vurdering: IAktivitetspliktVurderingNyDto): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vi kaller vel "vurdering" her både for aktivitet og unntak, så kanskje loeperUnntakEtterSisteAktivitet?

const nyesteVurdering = [...vurdering.aktivitet]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trenger vi å lage en ny array her egentlig, kan du ikke bare returnere siste element? :D

.sort((a, b) => new Date(a.fom).getTime() - new Date(b.fom).getTime())
.pop()
if (!nyesteVurdering) {
return true
}
const nyesteFom = new Date(nyesteVurdering.fom)

const harUnntakSomLoeper = vurdering.unntak.some((unntak) => !unntak.tom || new Date(unntak.tom) >= nyesteFom)
return harUnntakSomLoeper
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return in place

}

export function LoependeUnntakInfo() {
const { aktivtetspliktbrevdata, vurdering } = useAktivitetspliktOppgaveVurdering()
const harUnntakLoepende = loeperUnntakEtterSisteVurdering(vurdering)
if (aktivtetspliktbrevdata?.brevId && harUnntakLoepende) {
return (
<Alert variant="info">
Det er unntak som gjelder for samme periode som den siste vurderingen av aktivitet. Hvis unntaket er gjeldende
må innhold i brevet tilpasses.
</Alert>
)
} else {
return null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ 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'

interface IBrevAktivitetsplikt {
skalSendeBrev: JaNei
Expand Down Expand Up @@ -58,7 +59,6 @@ export const ValgForInfobrev = () => {
const [lagrebrevdataStatus, lagrebrevdata, tilbakestillApiResult] = useApiCall(lagreAktivitetspliktBrevdata)
const [redigeres, setRedigeres] = useState<boolean>(!aktivtetspliktbrevdata)
const brevdata = aktivtetspliktbrevdata

const lagreBrevutfall = (data: IBrevAktivitetsplikt) => {
const brevdatamappedToDo = mapToDto(data)
lagrebrevdata(
Expand Down Expand Up @@ -199,6 +199,7 @@ export const ValgForInfobrev = () => {
{aktivtetspliktbrevdata?.brevId && (
<Alert variant="info">Hvis valgene redigeres vil innholdet i brevet tilbakestilles.</Alert>
)}
<LoependeUnntakInfo />
</>
)}
</VStack>
Expand Down