From 663bfd29dc644c9759282487f3371d5e5aa89671 Mon Sep 17 00:00:00 2001 From: kristenhaerum Date: Thu, 8 Aug 2024 11:16:06 +0200 Subject: [PATCH] Add support for Pensjonsavtale data 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. --- .../form/partials/Pensjonsavtaler.tsx | 74 +++++++++++ .../visning/PensjonsavtaleVisning.tsx | 85 +++++++++++++ .../src/main/js/playwright/globalSetup.tsx | 5 + .../main/js/playwright/mocks/BasicMocks.tsx | 2 + .../kriterier/BestillingKriterieMapper.tsx | 37 +++--- .../fagsystem/pensjonsavtale/form/Form.tsx | 72 +++++++---- .../form/partials/Utbetalingsperioder.tsx | 107 +++++++--------- .../pensjonsavtale/form/validation.tsx | 16 +++ .../fagsystem/pensjonsavtale/initalValues.tsx | 46 ++++++- .../visning/PensjonsavtaleVisning.tsx | 116 ++++++++++++++++++ .../gruppe/PersonVisning/PersonVisning.tsx | 14 +++ .../src/main/js/src/service/SelectOptions.tsx | 28 +++++ .../js/src/utils/SjekkBestillingFagsystem.tsx | 10 ++ .../js/src/utils/hooks/useFagsystemer.tsx | 24 ++++ 14 files changed, 523 insertions(+), 113 deletions(-) create mode 100644 apps/dolly-backend/src/main/js/src/components/fagsystem/pensjonsavtale/form/partials/Pensjonsavtaler.tsx create mode 100644 apps/dolly-backend/src/main/js/src/components/fagsystem/pensjonsavtale/visning/PensjonsavtaleVisning.tsx create mode 100644 apps/dolly-frontend/src/main/js/src/components/fagsystem/pensjonsavtale/form/validation.tsx create mode 100644 apps/dolly-frontend/src/main/js/src/components/fagsystem/pensjonsavtale/visning/PensjonsavtaleVisning.tsx diff --git a/apps/dolly-backend/src/main/js/src/components/fagsystem/pensjonsavtale/form/partials/Pensjonsavtaler.tsx b/apps/dolly-backend/src/main/js/src/components/fagsystem/pensjonsavtale/form/partials/Pensjonsavtaler.tsx new file mode 100644 index 00000000000..ab5eb3eab37 --- /dev/null +++ b/apps/dolly-backend/src/main/js/src/components/fagsystem/pensjonsavtale/form/partials/Pensjonsavtaler.tsx @@ -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 ( + + + {(avtalePath) => ( + <> +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ + + )} +
+
+ ) +} diff --git a/apps/dolly-backend/src/main/js/src/components/fagsystem/pensjonsavtale/visning/PensjonsavtaleVisning.tsx b/apps/dolly-backend/src/main/js/src/components/fagsystem/pensjonsavtale/visning/PensjonsavtaleVisning.tsx new file mode 100644 index 00000000000..11172bb2457 --- /dev/null +++ b/apps/dolly-backend/src/main/js/src/components/fagsystem/pensjonsavtale/visning/PensjonsavtaleVisning.tsx @@ -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 ( + <> +
+ + + + + + + + + +
+ + ) +} + +export const PensjonsavtaleVisning = ({ data, loading, bestillingIdListe, tilgjengeligMiljoe }) => { + const { bestilteMiljoer } = useBestilteMiljoer(bestillingIdListe, 'PEN_PENSJONSAVTALE') + + if (loading) { + return + } + + 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 ( + + + {manglerFagsystemdata ? ( + + Fant ikke pensjonsavtale-data på person + + ) : ( + + + + )} + + ) +} diff --git a/apps/dolly-frontend/src/main/js/playwright/globalSetup.tsx b/apps/dolly-frontend/src/main/js/playwright/globalSetup.tsx index 827112dc97f..974baa7f36b 100644 --- a/apps/dolly-frontend/src/main/js/playwright/globalSetup.tsx +++ b/apps/dolly-frontend/src/main/js/playwright/globalSetup.tsx @@ -29,6 +29,7 @@ import { organisasjonFraMiljoeMock, paginerteGrupperMock, pensjonMock, + pensjonPensjonsavtaleMock, pensjonTpMock, personFragmentNavigerMock, personFragmentSearchMock, @@ -82,6 +83,9 @@ const skjerming = new RegExp(/dolly-backend\/api\/v1\/skjerming/) const pensjon = new RegExp(/testnav-pensjon-testdata-facade-proxy\/api\/v1\/inntekt/) const pensjonMiljoer = new RegExp(/testnav-pensjon-testdata-facade-proxy\/api\/v1\/miljo/) const pensjonTp = new RegExp(/testnav-pensjon-testdata-facade-proxy\/api\/v1\/tp(.*?)q1/) +const pensjonPensjonsavtale = new RegExp( + /testnav-pensjon-testdata-facade-proxy\/api\/v1\/pensjonsavtale\/hent/, +) const krrstub = new RegExp(/testnav-krrstub-proxy\/api\/v2/) const udistub = new RegExp(/testnav-udistub-proxy\/api\/v1/) const brregstub = new RegExp(/testnav-brregstub/) @@ -142,6 +146,7 @@ const mockRoutes: RouteInfo[] = [ { url: inst, response: instMock }, { url: pensjon, response: pensjonMock }, { url: pensjonTp, response: pensjonTpMock }, + { url: pensjonPensjonsavtale, response: pensjonPensjonsavtaleMock }, { url: sigrunstub, response: sigrunstubMock }, { url: udistub, response: udistubMock }, { url: kodeverk, response: kodeverkMock }, diff --git a/apps/dolly-frontend/src/main/js/playwright/mocks/BasicMocks.tsx b/apps/dolly-frontend/src/main/js/playwright/mocks/BasicMocks.tsx index 857d74b72ad..f861792b266 100644 --- a/apps/dolly-frontend/src/main/js/playwright/mocks/BasicMocks.tsx +++ b/apps/dolly-frontend/src/main/js/playwright/mocks/BasicMocks.tsx @@ -881,6 +881,8 @@ export const pensjonMock = [ export const pensjonTpMock = [{ ordning: '4095' }, { ordning: '3010' }] +export const pensjonPensjonsavtaleMock = [{}, {}] + export const tagsMock = [{ tag: 'DUMMY', beskrivelse: 'Dummy' }] export const kontoregisterMock = { diff --git a/apps/dolly-frontend/src/main/js/src/components/bestilling/sammendrag/kriterier/BestillingKriterieMapper.tsx b/apps/dolly-frontend/src/main/js/src/components/bestilling/sammendrag/kriterier/BestillingKriterieMapper.tsx index c4d8fd82502..76338831be2 100644 --- a/apps/dolly-frontend/src/main/js/src/components/bestilling/sammendrag/kriterier/BestillingKriterieMapper.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/bestilling/sammendrag/kriterier/BestillingKriterieMapper.tsx @@ -1903,29 +1903,32 @@ const mapPensjon = (bestillingData, data, navEnheter) => { data.push(pensjonforvalterPopp) } - if (pensjonKriterier.pensjonsavtale) { - const avtale = pensjonKriterier.pensjonsavtale - + if (pensjonKriterier.pensjonsavtale && pensjonKriterier.pensjonsavtale.length > 0) { const penPensjonsavtale = { header: 'Pensjonsavtale (PEN)', - items: [ - obj('Produktbetegnelse', avtale.produktBetegnelse), - obj('Avtalekategori', avtale.avtaleKategori), - obj('Startalder År', avtale.startAlderAar), - obj('Sluttalder År', avtale.sluttAlderAar), - ], itemRows: [], } - avtale.utbetalingsperioder.forEach((periode, i) => { + + pensjonKriterier.pensjonsavtale.forEach((pensjonsavtale, i) => { penPensjonsavtale.itemRows.push([ - { numberHeader: `Utbetalingsperiode ${i + 1}` }, - obj('Startalder År', periode.startAlderAar), - obj('StartAlderMaaneder', periode.startAlderMaaneder), - obj('Sluttalder År', periode.sluttAlderAar), - obj('Sluttalder Måneder', periode.sluttAlderMaaneder), - obj('Årlig Utbetaling', periode.aarligUtbetaling), - obj('Grad', periode.grad), + { numberHeader: `Pensjonsavtale ${i + 1}` }, + obj('Produktbetegnelse', pensjonsavtale.produktBetegnelse), + obj('Avtalekategori', pensjonsavtale.avtaleKategori), + obj('Startalder År', pensjonsavtale.startAlderAar), + obj('Sluttalder År', pensjonsavtale.sluttAlderAar), ]) + + pensjonsavtale.utbetalingsPerioder.forEach((periode, j) => { + penPensjonsavtale.itemRows.push([ + { numberHeader: `Utbetalingsperiode ${j + 1}` }, + obj('Startalder År', periode.startAlderAar), + obj('Startalder Måned', periode.startAlderMaaneder), + obj('Sluttalder År', periode.sluttAlderAar), + obj('Sluttalder Måned', periode.sluttAlderMaaneder), + obj('Årlig Utbetaling', periode.aarligUtbetaling), + obj('Grad', periode.grad), + ]) + }) }) data.push(penPensjonsavtale) diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/pensjonsavtale/form/Form.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/pensjonsavtale/form/Form.tsx index 53622109d8f..4f57b7e1300 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/pensjonsavtale/form/Form.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/pensjonsavtale/form/Form.tsx @@ -1,13 +1,15 @@ import React from 'react' +import { validation } from '@/components/fagsystem/pensjonsavtale/form/validation' +import { useFormContext } from 'react-hook-form' import { Vis } from '@/components/bestillingsveileder/VisAttributt' import Panel from '@/components/ui/panel/Panel' import { erForsteEllerTest, panelError } from '@/components/ui/form/formUtils' -import { validation } from '@/components/fagsystem/tjenestepensjon/form/validation' -import { SelectOptionsManager as Options } from '@/service/SelectOptions' -import { FormSelect } from '@/components/ui/form/inputs/select/Select' -import { useFormContext } from 'react-hook-form' import { FormTextInput } from '@/components/ui/form/inputs/textInput/TextInput' -import { UtbetalingsperioderForm } from '@/components/fagsystem/pensjonsavtale/form/partials/Utbetalingsperioder' // import './TPForm.less' +import { FormSelect } from '@/components/ui/form/inputs/select/Select' +import { SelectOptionsManager as Options } from '@/service/SelectOptions' +import { UtbetalingsperioderForm } from '@/components/fagsystem/pensjonsavtale/form/partials/Utbetalingsperioder' +import { FormDollyFieldArray } from '@/components/ui/form/fieldArray/DollyFieldArray' +import { initialNyPensjonsavtaleVerdier } from '@/components/fagsystem/pensjonsavtale/initalValues' // import './TPForm.less' // import './TPForm.less' export const avtalePath = 'pensjonforvalter.pensjonsavtale' @@ -26,26 +28,46 @@ export const PensjonsavtaleForm = () => { startOpen={erForsteEllerTest(formMethods.getValues(), [avtalePath])} informasjonstekst={hjelpetekst} > -
- - - - - - - - - -
+ + {(formPath, idx) => ( + + +
+ + + + + + + + + +
+
+
+ )} +
) diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/pensjonsavtale/form/partials/Utbetalingsperioder.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/pensjonsavtale/form/partials/Utbetalingsperioder.tsx index 496779cd6c5..1478f5f3e8a 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/pensjonsavtale/form/partials/Utbetalingsperioder.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/pensjonsavtale/form/partials/Utbetalingsperioder.tsx @@ -1,74 +1,49 @@ 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 { - initialUtbetalingsperiode, - initialUtbetalingsperiodeVerdier, -} from '@/components/fagsystem/pensjonsavtale/initalValues' import { FormTextInput } from '@/components/ui/form/inputs/textInput/TextInput' +import { SelectOptionsManager as Options } from '@/service/SelectOptions' +import { FormSelect } from '@/components/ui/form/inputs/select/Select' +import { initialUtbetalingsperiodeVerdier } from '@/components/fagsystem/pensjonsavtale/initalValues' -export const UtbetalingsperioderForm = ({ formMethods }) => { - const perioderPath = 'pensjonforvalter.pensjonsavtale.utbetalingsperioder' - +export const UtbetalingsperioderForm = ({ path }: any) => { return ( - - - {(perioderPath) => ( - <> -
- -
-
- -
-
- -
-
- -
-
- -
-
- -
- + {(path: any, idx: React.Key) => ( + +
+ + + + + + - - )} - - +
+
+ )} +
) } diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/pensjonsavtale/form/validation.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/pensjonsavtale/form/validation.tsx new file mode 100644 index 00000000000..5b72919e59e --- /dev/null +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/pensjonsavtale/form/validation.tsx @@ -0,0 +1,16 @@ +import * as Yup from 'yup' +import { ifPresent } from '@/utils/YupValidations' + +export const validation = { + tp: ifPresent( + '$pensjonforvalter.pensjonsavtale', + Yup.array().of( + Yup.object({ + produktBetegnelse: Yup.string().required().typeError('Feltet er påkrevd'), + avtaleKategori: Yup.string().required().typeError('Feltet er påkrevd'), + startAlderAar: Yup.number().min(17).max(72), + sluttAlderAar: Yup.number().min(17).max(72), + }), + ), + ), +} diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/pensjonsavtale/initalValues.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/pensjonsavtale/initalValues.tsx index cd5331e8364..c20e2885fab 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/pensjonsavtale/initalValues.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/pensjonsavtale/initalValues.tsx @@ -1,4 +1,23 @@ -export const initialPensjonsavtale = { +export const initialPensjonsavtale = [ + { + produktBetegnelse: 'Test av pensjonsavtale', + avtaleKategori: 'FOLKETRYGD', + startAlderAar: 22, + sluttAlderAar: 62, + utbetalingsperioder: [ + { + startAlderAar: 62, + startAlderMaaneder: 12, + sluttAlderAar: 72, + sluttAlderMaaneder: 12, + aarligUtbetaling: 200000, + grad: 100, + }, + ], + }, +] + +export const initialNyPensjonsavtaleVerdier = { produktBetegnelse: 'Test av pensjonsavtale', avtaleKategori: 'FOLKETRYGD', startAlderAar: 22, @@ -15,11 +34,28 @@ export const initialPensjonsavtale = { ], } +export const initialNyPensjonsavtale = { + produktBetegnelse: '', + avtaleKategori: '', + startAlderAar: undefined, + sluttAlderAar: undefined, + utbetalingsperioder: [ + { + startAlderAar: undefined, + startAlderMaaneder: undefined, + sluttAlderAar: undefined, + sluttAlderMaaneder: undefined, + aarligUtbetaling: undefined, + grad: undefined, + }, + ], +} + export const initialUtbetalingsperiodeVerdier = { - startAlderAar: 62, - startAlderMaaneder: 12, - sluttAlderAar: 72, - sluttAlderMaaneder: 12, + startAlderAar: 67, + startAlderMaaneder: 1, + sluttAlderAar: undefined, + sluttAlderMaaneder: undefined, aarligUtbetaling: 200000, grad: 100, } diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/pensjonsavtale/visning/PensjonsavtaleVisning.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/pensjonsavtale/visning/PensjonsavtaleVisning.tsx new file mode 100644 index 00000000000..9057c2d2924 --- /dev/null +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/pensjonsavtale/visning/PensjonsavtaleVisning.tsx @@ -0,0 +1,116 @@ +import SubOverskrift from '@/components/ui/subOverskrift/SubOverskrift' +import { TitleValue } from '@/components/ui/titleValue/TitleValue' +import Loading from '@/components/ui/loading/Loading' +import { DollyFieldArray } from '@/components/ui/form/fieldArray/DollyFieldArray' +import { ErrorBoundary } from '@/components/ui/appError/ErrorBoundary' +import Panel from '@/components/ui/panel/Panel' +import { runningE2ETest } from '@/service/services/Request' +import { Alert } from '@navikt/ds-react' +import { MiljoTabs } from '@/components/ui/miljoTabs/MiljoTabs' +import { useBestilteMiljoer } from '@/utils/hooks/useBestilling' + +export const sjekkManglerPensjonData = (pensjonData) => { + return ( + pensjonData?.length < 1 || + pensjonData?.every((miljoData) => miljoData?.data?.utbetalingsperioder?.length < 1) + ) +} + +const Utbetalingsperioder = ({ utbetalingsperioder, isPanelOpen, setPanelOpen }) => { + if (!utbetalingsperioder) return null + + return ( + + {(utbetalingsperiode, idx) => ( +
+ + + + + + +
+ )} +
+ ) +} + +const Pensjonsavtale = ({ data, isPanelOpen, setPanelOpen }) => { + if (!data) return null + console.log('data', data) + console.log('isPanelOpen', isPanelOpen) + console.log('setPanelOpen', setPanelOpen) + return ( + + + {(pensjonsavtale, idx) => ( +
+ + + + + +
+ )} +
+
+ ) +} + +export const PensjonsavtaleVisning = ({ data, loading, bestillingIdListe, tilgjengeligMiljoe }) => { + const { bestilteMiljoer } = useBestilteMiljoer(bestillingIdListe, 'PEN_INNTEKT') + + if (loading) { + return + } + if (!data) { + return null + } + + console.log('data', data) + + const manglerFagsystemdata = sjekkManglerPensjonData(data) + + const miljoerMedData = data?.map((miljoData) => miljoData.data?.length > 0 && miljoData.miljo) + const errorMiljoer = bestilteMiljoer.filter((miljo) => !miljoerMedData?.includes(miljo)) + + const forsteMiljo = data.find((miljoData) => miljoData?.data)?.miljo + + console.log('bestilteMiljoer', bestilteMiljoer) + + console.log('foresteMiljo', forsteMiljo) + + const filteredData = + tilgjengeligMiljoe && data.filter((item) => tilgjengeligMiljoe.includes(item.miljo)) + + return ( + + + {manglerFagsystemdata ? ( + + Fant ikke pensjonsavtale-data for person + + ) : ( + + + + )} + + ) +} diff --git a/apps/dolly-frontend/src/main/js/src/pages/gruppe/PersonVisning/PersonVisning.tsx b/apps/dolly-frontend/src/main/js/src/pages/gruppe/PersonVisning/PersonVisning.tsx index 5d8bbc2c9b5..346f553afde 100644 --- a/apps/dolly-frontend/src/main/js/src/pages/gruppe/PersonVisning/PersonVisning.tsx +++ b/apps/dolly-frontend/src/main/js/src/pages/gruppe/PersonVisning/PersonVisning.tsx @@ -42,6 +42,7 @@ import { useDokarkivData, useHistarkData, useInstData, + usePensjonsavtaleData, usePoppData, useTpData, useTransaksjonIdData, @@ -58,6 +59,7 @@ import { harInntektsmeldingBestilling, harInstBestilling, harMedlBestilling, + harPensjonavtaleBestilling, harPoppBestilling, harSykemeldingBestilling, harTpBestilling, @@ -90,6 +92,7 @@ import { useTenorIdent } from '@/utils/hooks/useTenorSoek' import { SkatteetatenVisning } from '@/components/fagsystem/skatteetaten/visning/SkatteetatenVisning' import PdlVisningConnector from '@/components/fagsystem/pdl/visning/PdlVisningConnector' import { useOrganisasjonMiljoe } from '@/utils/hooks/useOrganisasjonTilgang' +import { PensjonsavtaleVisning } from '@/components/fagsystem/pensjonsavtale/visning/PensjonsavtaleVisning' const getIdenttype = (ident) => { if (parseInt(ident.charAt(0)) > 3) { @@ -164,6 +167,11 @@ export default ({ harTpBestilling(bestillingerFagsystemer), ) + const { loading: loadingPensjonsavtaleData, pensjonsavtaleData } = usePensjonsavtaleData( + ident.ident, + harPensjonavtaleBestilling(bestillingerFagsystemer), + ) + const { loading: loadingPoppData, poppData } = usePoppData( ident.ident, harPoppBestilling(bestillingerFagsystemer), @@ -466,6 +474,12 @@ export default ({ bestillingIdListe={bestillingIdListe} tilgjengeligMiljoe={tilgjengeligMiljoe} /> + { return alderspensjon } +export const harPensjonavtaleBestilling = (bestillingerFagsystemer) => { + let pensjonavtale = false + bestillingerFagsystemer?.forEach((i) => { + if (i?.pensjonforvalter?.pensjonsavtale) { + pensjonavtale = true + } + }) + return pensjonavtale +} + export const harUforetrygdBestilling = (bestillingerFagsystemer) => { let uforetrygd = false bestillingerFagsystemer?.forEach((i) => { diff --git a/apps/dolly-frontend/src/main/js/src/utils/hooks/useFagsystemer.tsx b/apps/dolly-frontend/src/main/js/src/utils/hooks/useFagsystemer.tsx index 8a01a5b3e37..bd359e068d1 100644 --- a/apps/dolly-frontend/src/main/js/src/utils/hooks/useFagsystemer.tsx +++ b/apps/dolly-frontend/src/main/js/src/utils/hooks/useFagsystemer.tsx @@ -22,6 +22,12 @@ const poppUrl = (ident, miljoer) => miljo: miljo, })) +const pensjonsavtaleUrl = (miljoer) => + miljoer?.map((miljo) => ({ + url: `/testnav-pensjon-testdata-facade-proxy/api/v1/pensjonsavtale/hent?miljo=${miljo}`, + miljo: miljo, + })) + const tpUrl = (ident, miljoer) => miljoer?.map((miljo) => ({ url: `/testnav-pensjon-testdata-facade-proxy/api/v1/tp/forhold?fnr=${ident}&miljo=${miljo}`, @@ -87,6 +93,24 @@ export const usePoppData = (ident, harPoppBestilling) => { } } +export const usePensjonsavtaleData = (ident, harPensjonsavtaleBestilling) => { + const { pensjonEnvironments } = usePensjonEnvironments() + + const { data, isLoading, error } = useSWR( + [ + harPensjonsavtaleBestilling ? pensjonsavtaleUrl(pensjonEnvironments) : null, + { 'Nav-Call-Id': 'dolly', 'Nav-Consumer-Id': 'dolly', Authorization: 'dolly', ident: ident }, + ], + ([url, headers]) => multiFetcherPensjon(url, headers), + ) + + return { + pensjonsavtaleData: data?.sort((a, b) => a.miljo.localeCompare(b.miljo)), + loading: isLoading, + error: error, + } +} + export const useTpData = (ident, harTpBestilling) => { const { pensjonEnvironments } = usePensjonEnvironments()