Skip to content

Commit

Permalink
Simplified environment handling in Dolly frontend
Browse files Browse the repository at this point in the history
#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.
  • Loading branch information
krharum committed May 3, 2024
1 parent 92e93a0 commit 9793b09
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ private Function<PredicateSpec, Buildable<Route>> createRoute(String segment, St
.filters(filter, addUserJwtHeaderFilter())
).uri(host);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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) => {
Expand All @@ -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', [])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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()

Expand All @@ -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')
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import _ from 'lodash'
import { Alert } from '@navikt/ds-react'
import {
useArenaEnvironments,
Expand All @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ private Function<PredicateSpec, Buildable<Route>> createRoute(ServerProperties s
.filter(filter)
).uri(host);
}
}
}

0 comments on commit 9793b09

Please sign in to comment.