-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhanced the application to handle Pensjonsavtale data by adding new components and necessary validation logic. Updated existing components and services to integrate the new functionality seamlessly.
- Loading branch information
Showing
14 changed files
with
523 additions
and
113 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
...end/src/main/js/src/components/fagsystem/pensjonsavtale/form/partials/Pensjonsavtaler.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { FormDollyFieldArray } from '@/components/ui/form/fieldArray/DollyFieldArray' | ||
import * as React from 'react' | ||
import { Vis } from '@/components/bestillingsveileder/VisAttributt' | ||
import { EraseFillButtons } from '@/components/fagsystem/arbeidsplassen/form/partials/EraseFillButtons' | ||
import { | ||
initialNyPensjonsavtale, | ||
initialNyPensjonsavtaleVerdier, | ||
} from '@/components/fagsystem/pensjonsavtale/initalValues' | ||
import { FormTextInput } from '@/components/ui/form/inputs/textInput/TextInput' | ||
|
||
export const PensjonsavtalerForm = ({ formMethods }) => { | ||
const avtalePath = 'pensjonforvalter.pensjonsavtale' | ||
|
||
return ( | ||
<Vis attributt={avtalePath}> | ||
<FormDollyFieldArray | ||
name={avtalePath} | ||
header="Pensjonsavtale" | ||
newEntry={initialNyPensjonsavtaleVerdier} | ||
buttonText="Utbetalingsperiode" | ||
nested | ||
> | ||
{(avtalePath) => ( | ||
<> | ||
<div className="flexbox--flex-wrap"> | ||
<FormTextInput | ||
name={`${avtalePath}.startAlderAar`} | ||
label="Startalder År" | ||
type="number" | ||
/> | ||
</div> | ||
<div className="flexbox--flex-wrap"> | ||
<FormTextInput | ||
name={`${avtalePath}.startAlderMaaneder`} | ||
label="Startalder Måneder" | ||
type="number" | ||
/> | ||
</div> | ||
<div className="flexbox--flex-wrap"> | ||
<FormTextInput | ||
name={`${avtalePath}.sluttAlderAar`} | ||
label="Sluttalder År" | ||
type="number" | ||
/> | ||
</div> | ||
<div className="flexbox--flex-wrap"> | ||
<FormTextInput | ||
name={`${avtalePath}.sluttAlderMaaneder`} | ||
label="Sluttalder Måneder" | ||
type="number" | ||
/> | ||
</div> | ||
<div className="flexbox--flex-wrap"> | ||
<FormTextInput | ||
name={`${avtalePath}.aarligUtbetaling`} | ||
label="Årlig utbetaling" | ||
type="number" | ||
/> | ||
</div> | ||
<div className="flexbox--flex-wrap"> | ||
<FormTextInput name={`${avtalePath}.grad`} label="Grad" type="number" /> | ||
</div> | ||
<EraseFillButtons | ||
formMethods={formMethods} | ||
path={avtalePath} | ||
initialFill={initialNyPensjonsavtaleVerdier} | ||
initialErase={initialNyPensjonsavtale} | ||
/> | ||
</> | ||
)} | ||
</FormDollyFieldArray> | ||
</Vis> | ||
) | ||
} |
85 changes: 85 additions & 0 deletions
85
...end/src/main/js/src/components/fagsystem/pensjonsavtale/visning/PensjonsavtaleVisning.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import SubOverskrift from '@/components/ui/subOverskrift/SubOverskrift' | ||
import { TitleValue } from '@/components/ui/titleValue/TitleValue' | ||
import React from 'react' | ||
import { formatDate } from '@/utils/DataFormatter' | ||
import Loading from '@/components/ui/loading/Loading' | ||
import { useBestilteMiljoer } from '@/utils/hooks/useBestilling' | ||
import { ErrorBoundary } from '@/components/ui/appError/ErrorBoundary' | ||
import { Alert } from '@navikt/ds-react' | ||
import { MiljoTabs } from '@/components/ui/miljoTabs/MiljoTabs' | ||
import { useNavEnheter } from '@/utils/hooks/useNorg2' | ||
import { usePensjonVedtak } from '@/utils/hooks/usePensjon' | ||
|
||
export const sjekkManglerPensjonsavtaleData = (pensjonsavtaleData) => { | ||
return pensjonsavtaleData?.length < 1 || pensjonsavtaleData?.every((miljoData) => !miljoData.data) | ||
} | ||
|
||
const DataVisning = ({ data, miljo }) => { | ||
const { navEnheter } = useNavEnheter() | ||
const navEnhetLabel = navEnheter?.find( | ||
(enhet) => enhet.value === data?.navEnhetId?.toString(), | ||
)?.label | ||
|
||
const { vedtakData } = usePensjonVedtak(data?.fnr, miljo) | ||
|
||
return ( | ||
<> | ||
<div className="person-visning_content"> | ||
<TitleValue title="Vedtaksstatus" value={vedtakData?.[0]?.vedtakStatus} /> | ||
<TitleValue title="Krav fremsatt dato" value={formatDate(data?.kravFremsattDato)} /> | ||
<TitleValue title="Iverksettelsesdato" value={formatDate(data?.iverksettelsesdato)} /> | ||
<TitleValue title="Saksbehandler" value={data?.saksbehandler} /> | ||
<TitleValue title="Attesterer" value={data?.attesterer} /> | ||
<TitleValue title="Uttaksgrad" value={`${data?.uttaksgrad}%`} /> | ||
<TitleValue title="NAV-kontor" value={navEnhetLabel || data?.navEnhetId} /> | ||
|
||
<TitleValue | ||
title="Ektefelle/partners inntekt" | ||
value={data?.relasjonListe?.[0]?.sumAvForventetArbeidKapitalPensjonInntekt} | ||
/> | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
export const PensjonsavtaleVisning = ({ data, loading, bestillingIdListe, tilgjengeligMiljoe }) => { | ||
const { bestilteMiljoer } = useBestilteMiljoer(bestillingIdListe, 'PEN_PENSJONSAVTALE') | ||
|
||
if (loading) { | ||
return <Loading label="Laster pensjonsavtale-data" /> | ||
} | ||
|
||
if (!data) { | ||
return null | ||
} | ||
|
||
const manglerFagsystemdata = sjekkManglerPensjonsavtaleData(data) | ||
|
||
const miljoerMedData = data?.map((miljoData) => miljoData.data && miljoData.miljo) | ||
const errorMiljoer = bestilteMiljoer?.filter((miljo) => !miljoerMedData?.includes(miljo)) | ||
|
||
const forsteMiljo = data.find((miljoData) => miljoData?.data)?.miljo | ||
|
||
const filteredData = | ||
tilgjengeligMiljoe && data.filter((item) => tilgjengeligMiljoe.includes(item.miljo)) | ||
|
||
return ( | ||
<ErrorBoundary> | ||
<SubOverskrift label="Pensjonsavtale" iconKind="pensjon" isWarning={manglerFagsystemdata} /> | ||
{manglerFagsystemdata ? ( | ||
<Alert variant={'warning'} size={'small'} inline style={{ marginBottom: '20px' }}> | ||
Fant ikke pensjonsavtale-data på person | ||
</Alert> | ||
) : ( | ||
<MiljoTabs | ||
bestilteMiljoer={bestilteMiljoer} | ||
errorMiljoer={errorMiljoer} | ||
forsteMiljo={forsteMiljo} | ||
data={filteredData ? filteredData : data} | ||
> | ||
<DataVisning /> | ||
</MiljoTabs> | ||
)} | ||
</ErrorBoundary> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.