From 9793b09465ddf6121e5f7058979223e544122625 Mon Sep 17 00:00:00 2001 From: kristenhaerum Date: Fri, 3 May 2024 14:03:56 +0200 Subject: [PATCH] Simplified environment handling in Dolly frontend #deploy-idporten-frontend #deploy-organisasjon-tilgang-frontend Removed several dependencies on pdldata for environment determination, simplifying the logic. Refactored how available environments are checked and set for BankID users. The changes impact the Dolly frontend, particularly in the modules DollyFrontendApplicationStarter, MiljoeInfo, Steg3, OrganisasjonTilgangFrontendApplicationStarter, and MiljoVelger. --- .../web/DollyFrontendApplicationStarter.java | 2 +- .../stegVelger/steg/steg3/Steg3.tsx | 12 +---- .../components/miljoVelger/MiljoVelger.tsx | 45 ++++++++++--------- .../src/components/miljoVelger/MiljoeInfo.tsx | 17 +------ ...sjonTilgangFrontendApplicationStarter.java | 2 +- 5 files changed, 29 insertions(+), 49 deletions(-) diff --git a/apps/dolly-frontend/src/main/java/no/nav/dolly/web/DollyFrontendApplicationStarter.java b/apps/dolly-frontend/src/main/java/no/nav/dolly/web/DollyFrontendApplicationStarter.java index 1250d63cceb..06c00ec7121 100644 --- a/apps/dolly-frontend/src/main/java/no/nav/dolly/web/DollyFrontendApplicationStarter.java +++ b/apps/dolly-frontend/src/main/java/no/nav/dolly/web/DollyFrontendApplicationStarter.java @@ -131,4 +131,4 @@ private Function> createRoute(String segment, St .filters(filter, addUserJwtHeaderFilter()) ).uri(host); } -} +} \ No newline at end of file diff --git a/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/stegVelger/steg/steg3/Steg3.tsx b/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/stegVelger/steg/steg3/Steg3.tsx index 1015f43bd26..5fea9928f64 100644 --- a/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/stegVelger/steg/steg3/Steg3.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/stegVelger/steg/steg3/Steg3.tsx @@ -28,12 +28,6 @@ export const Steg3 = () => { const importTestnorge = opts.is.importTestnorge const erOrganisasjon = formMethods.getValues('organisasjon') - const erQ2MiljoeAvhengig = - formMethods.watch('pdldata.person.fullmakt') || - formMethods.watch('pdldata.person.falskIdentitet') || - formMethods.watch('pdldata.person.falskIdentitet') || - formMethods.watch('pdldata.person.utenlandskIdentifikasjonsnummer') || - formMethods.watch('pdldata.person.kontaktinformasjonForDoedsbo') const bankIdBruker = currentBruker?.brukertype === 'BANKID' @@ -50,9 +44,9 @@ export const Steg3 = () => { if (loading) { return [] } else if (bankIdBruker) { - return tilgjengeligMiljoe ? [tilgjengeligMiljoe] : ['q1'] + return tilgjengeligMiljoe ? tilgjengeligMiljoe.split(',') : ['q1'] } - return erQ2MiljoeAvhengig ? ['q2'] : [] + return [] } const erQ1EllerQ2MiljoeAvhengig = (values: any) => { @@ -73,8 +67,6 @@ export const Steg3 = () => { formMethods.setValue('environments', ['q1', 'q2']) } else if (formMethods.getValues()?.sykemelding) { formMethods.setValue('environments', ['q1']) - } else if (erQ2MiljoeAvhengig) { - formMethods.setValue('environments', alleredeValgtMiljoe()) } else if (!formMethods.getValues()?.environments) { formMethods.setValue('environments', []) } diff --git a/apps/dolly-frontend/src/main/js/src/components/miljoVelger/MiljoVelger.tsx b/apps/dolly-frontend/src/main/js/src/components/miljoVelger/MiljoVelger.tsx index 63d721634ed..b1e4da60424 100644 --- a/apps/dolly-frontend/src/main/js/src/components/miljoVelger/MiljoVelger.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/miljoVelger/MiljoVelger.tsx @@ -17,19 +17,15 @@ const StyledH3 = styled.h3` align-items: center; ` -const bankIdQ1 = [ - { - id: 'q1', - label: 'Q1', - }, -] +const bankIdQ1 = { + id: 'q1', + label: 'Q1', +} -const bankIdQ2 = [ - { - id: 'q2', - label: 'Q2', - }, -] +const bankIdQ2 = { + id: 'q2', + label: 'Q2', +} const miljoeavhengig = [ 'aareg', @@ -54,13 +50,7 @@ const erMiljouavhengig = (bestilling) => { return miljoeNotRequired } -export const MiljoVelger = ({ - bestillingsdata, - heading, - bankIdBruker, - orgTilgang, - alleredeValgtMiljoe, -}) => { +export const MiljoVelger = ({ bestillingsdata, heading, bankIdBruker, alleredeValgtMiljoe }) => { const { dollyEnvironments, loading } = useDollyEnvironments() const formMethods = useFormContext() @@ -70,9 +60,20 @@ export const MiljoVelger = ({ const filterEnvironments = (miljoer, erBankIdBruker) => { if (erBankIdBruker) { - const tilgjengeligMiljo = orgTilgang?.miljoe - if (tilgjengeligMiljo === 'q1') return bankIdQ1 - return bankIdQ2 + var bankMiljoer = [] + for (var i = 0; i < alleredeValgtMiljoe.length; i++) { + switch (alleredeValgtMiljoe[i]) { + case 'q1': + bankMiljoer.push(bankIdQ1) + break + case 'q2': + bankMiljoer.push(bankIdQ2) + break + } + } + console.log('bankMiljoer', bankMiljoer) + + return bankMiljoer } return miljoer.Q.filter((env: any) => env.id !== 'qx') } diff --git a/apps/dolly-frontend/src/main/js/src/components/miljoVelger/MiljoeInfo.tsx b/apps/dolly-frontend/src/main/js/src/components/miljoVelger/MiljoeInfo.tsx index 2ec8ae93331..610078bc9b8 100644 --- a/apps/dolly-frontend/src/main/js/src/components/miljoVelger/MiljoeInfo.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/miljoVelger/MiljoeInfo.tsx @@ -1,4 +1,3 @@ -import _ from 'lodash' import { Alert } from '@navikt/ds-react' import { useArenaEnvironments, @@ -18,20 +17,8 @@ export const MiljoeInfo = ({ bestillingsdata, dollyEnvironments }) => { } = usePensjonEnvironments() const { instEnvironments, loading: loadingInst, error: errorInst } = useInstEnvironments() const { dokarkivEnvironments, loading: loadingDokarkiv } = useDokarkivEnvironments() - const { instdata, pdldata, arenaforvalter, pensjonforvalter, sykemelding, dokarkiv } = - bestillingsdata - if ( - !instdata && - !arenaforvalter && - !pensjonforvalter && - !sykemelding && - !dokarkiv && - !_.get(pdldata, 'bostedsadresse') && - !_.get(pdldata, 'fullmakt') && - !_.get(pdldata, 'falskIdentitet') && - !_.get(pdldata, 'utenlandskIdentifikasjonsnummer') && - !_.get(pdldata, 'kontaktinformasjonForDoedsbo') - ) { + const { instdata, arenaforvalter, pensjonforvalter, sykemelding, dokarkiv } = bestillingsdata + if (!instdata && !arenaforvalter && !pensjonforvalter && !sykemelding && !dokarkiv) { return null } diff --git a/apps/organisasjon-tilgang-frontend/src/main/java/no/nav/testnav/apps/organisasjontilgangfrontend/OrganisasjonTilgangFrontendApplicationStarter.java b/apps/organisasjon-tilgang-frontend/src/main/java/no/nav/testnav/apps/organisasjontilgangfrontend/OrganisasjonTilgangFrontendApplicationStarter.java index e6e15ed3d06..17092a5c8dd 100644 --- a/apps/organisasjon-tilgang-frontend/src/main/java/no/nav/testnav/apps/organisasjontilgangfrontend/OrganisasjonTilgangFrontendApplicationStarter.java +++ b/apps/organisasjon-tilgang-frontend/src/main/java/no/nav/testnav/apps/organisasjontilgangfrontend/OrganisasjonTilgangFrontendApplicationStarter.java @@ -66,4 +66,4 @@ private Function> createRoute(ServerProperties s .filter(filter) ).uri(host); } -} \ No newline at end of file +}