Skip to content

Commit

Permalink
Feature/org tilgang flere miljoer (#3484)
Browse files Browse the repository at this point in the history
Stotte for flere miljoer med BankId-brukere
  • Loading branch information
krharum authored May 6, 2024
1 parent a87bc25 commit a8b79bc
Show file tree
Hide file tree
Showing 22 changed files with 75 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/app.organisasjon-tilgang-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: ./.github/workflows/common.workflow.frontend.yml
with:
working-directory: "apps/organisasjon-tilgang-frontend"
deploy-tag: "#deploy-test-organisasjon-tilgang-frontend"
deploy-tag: "#deploy-organisasjon-tilgang-frontend"
permissions:
contents: read
id-token: write
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/proxy.dokarkiv-proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
with:
cluster: "dev-fss"
working-directory: "proxies/dokarkiv-proxy"
deploy-tag: "#deploy-proxy"
deploy-tag: "#deploy-dokarkiv-proxy"
permissions:
contents: read
id-token: write
Expand Down
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 @@ -321,7 +321,7 @@ export const AaregVisning = ({
})

const filteredData =
tilgjengeligMiljoe && arbeidsforhold?.filter((item) => item.miljo === tilgjengeligMiljoe)
tilgjengeligMiljoe && arbeidsforhold?.filter((item) => tilgjengeligMiljoe.includes(item.miljo))

const manglerArbeidsforholdData = sjekkManglerAaregData(arbeidsforhold)
const arbeidsforholdFeil =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ 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";
import { useNavEnheter } from '@/utils/hooks/useNorg2'
import { usePensjonVedtak } from '@/utils/hooks/usePensjon'

export const sjekkManglerApData = (apData) => {
return apData?.length < 1 || apData?.every((miljoData) => !miljoData.data)
}

const DataVisning = ({ data, miljo }) => {

const { navEnheter } = useNavEnheter()
const navEnhetLabel = navEnheter?.find((enhet) => enhet.value === data?.navEnhetId?.toString())
?.label
const navEnhetLabel = navEnheter?.find(
(enhet) => enhet.value === data?.navEnhetId?.toString(),
)?.label

const { vedtakData } = usePensjonVedtak(data?.fnr, miljo)

Expand Down Expand Up @@ -61,7 +61,7 @@ export const AlderspensjonVisning = ({ data, loading, bestillingIdListe, tilgjen
const forsteMiljo = data.find((miljoData) => miljoData?.data)?.miljo

const filteredData =
tilgjengeligMiljoe && data.filter((item) => item.miljo === tilgjengeligMiljoe)
tilgjengeligMiljoe && data.filter((item) => tilgjengeligMiljoe.includes(item.miljo))

return (
<ErrorBoundary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const ArenaVisning = ({ data, ident, bestillingIdListe, loading, tilgjeng
})

const filteredData =
tilgjengeligMiljoe && data?.filter((item) => item.miljo === tilgjengeligMiljoe)
tilgjengeligMiljoe && data?.filter((item) => tilgjengeligMiljoe.includes(item.miljo))

const forsteMiljo = data?.find((miljoData) => miljoData?.data)?.miljo

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default ({ data, bestillingIdListe, loading, tilgjengeligMiljoe }: Form)
const mergedData = mergeData()

const filteredData =
tilgjengeligMiljoe && mergedData?.filter((item) => item?.miljo === tilgjengeligMiljoe)
tilgjengeligMiljoe && mergedData?.filter((item) => tilgjengeligMiljoe.includes(item?.miljo))

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const getSortedData = (data) => {
const datoB = new Date(b.startdato)

return datoA < datoB ? 1 : datoA > datoB ? -1 : 0
})
})
: data
}

Expand Down Expand Up @@ -47,7 +47,7 @@ export const InstVisning = ({ data, loading, bestillingIdListe, tilgjengeligMilj
})

const filteredData =
tilgjengeligMiljoe && sortedData.filter((item) => item.miljo === tilgjengeligMiljoe)
tilgjengeligMiljoe && sortedData.filter((item) => tilgjengeligMiljoe.includes(item.miljo))

return (
<ErrorBoundary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const PensjonVisning = ({ data, loading, bestillingIdListe, tilgjengeligM
const forsteMiljo = data.find((miljoData) => miljoData?.data?.inntekter?.length > 0)?.miljo

const filteredData =
tilgjengeligMiljoe && data.filter((item) => item.miljo === tilgjengeligMiljoe)
tilgjengeligMiljoe && data.filter((item) => tilgjengeligMiljoe.includes(item.miljo))

return (
<ErrorBoundary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const SykemeldingVisning = ({
const forsteMiljo = data?.find((miljoData) => miljoData?.data)?.miljo

const filteredData =
tilgjengeligMiljoe && data?.filter((item) => item.miljo === tilgjengeligMiljoe)
tilgjengeligMiljoe && data?.filter((item) => tilgjengeligMiljoe.includes(item.miljo))

return (
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const TpVisning = ({ data, loading, bestillingIdListe, tilgjengeligMiljoe
const forsteMiljo = data.find((miljoData) => miljoData?.data?.length > 0)?.miljo

const filteredData =
tilgjengeligMiljoe && data.filter((item) => item.miljo === tilgjengeligMiljoe)
tilgjengeligMiljoe && data.filter((item) => tilgjengeligMiljoe.includes(item.miljo))

return (
<ErrorBoundary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ const BarnetilleggInntektVisning = ({ data, tittel }) => {

const DataVisning = ({ data, miljo }) => {
const { navEnheter } = useNavEnheter()
const navEnhetLabel = navEnheter?.find((enhet) => enhet.value === data?.navEnhetId?.toString())
?.label
const navEnhetLabel = navEnheter?.find(
(enhet) => enhet.value === data?.navEnhetId?.toString(),
)?.label

const { vedtakData } = usePensjonVedtak(data?.fnr, miljo)

Expand Down Expand Up @@ -111,7 +112,7 @@ export const UforetrygdVisning = ({ data, loading, bestillingIdListe, tilgjengel
const forsteMiljo = data.find((miljoData) => miljoData?.data)?.miljo

const filteredData =
tilgjengeligMiljoe && data.filter((item) => item.miljo === tilgjengeligMiljoe)
tilgjengeligMiljoe && data.filter((item) => tilgjengeligMiljoe.includes(item.miljo))

return (
<ErrorBoundary>
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,19 @@ 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
}
}

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 All @@ -51,18 +38,28 @@ export const MiljoeInfo = ({ bestillingsdata, dollyEnvironments }) => {
Du har valgt egenskaper som ikke blir distribuert til alle miljøer. For hver av følgende
egenskaper må derfor ett eller flere av miljøene under velges:
<ul style={{ margin: '7px 0' }}>
{instdata && (
<li>
Institusjonsopphold:&nbsp;
<span>{getMiljoer(instEnvironments, loadingInst, errorInst)}</span>
</li>
)}
{arenaforvalter && (
<li>
Arena:&nbsp;
<span>{getMiljoer(arenaEnvironments, loadingArena, errorArena)}</span>
</li>
)}
{dokarkiv && (
<li>
Dokarkiv:&nbsp;
<span>
{loadingDokarkiv
? 'Laster tilgjengelige miljøer..'
: arrayToString(dokarkivEnvironments)}
</span>
</li>
)}
{instdata && (
<li>
Institusjonsopphold:&nbsp;
<span>{getMiljoer(instEnvironments, loadingInst, errorInst)}</span>
</li>
)}

{(pensjonforvalter?.inntekt ||
pensjonforvalter?.tp ||
Expand All @@ -86,18 +83,7 @@ export const MiljoeInfo = ({ bestillingsdata, dollyEnvironments }) => {
</li>
)}

{sykemelding && <li>Sykemelding: Q1 må velges</li>}

{dokarkiv && (
<li>
Dokarkiv:&nbsp;
<span>
{loadingDokarkiv
? 'Laster tilgjengelige miljøer..'
: arrayToString(dokarkivEnvironments)}
</span>
</li>
)}
{sykemelding && <li>Sykemelding: q1</li>}
</ul>
</StyledAlert>
{pensjonforvalter && bestillingsdata?.environments?.includes('q4') && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const prefetchedMiljoer = ['t13', 'q1', 'q2', 'q4', 'qx']
const prefetchedPensjonMiljoer = ['q1', 'q2']
const prefetchedArenaMiljoer = ['q1', 'q2', 'q4']
const prefetchedInstMiljoer = { institusjonsoppholdEnvironments: ['q1', 'q2'] }
const prefetchedDokarkivMiljoer = ['q1', 'q2']
const prefetchedDokarkivMiljoer = ['q1', 'q2', 'q4']

type InstResponse = {
institusjonsoppholdEnvironments: string[]
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class SecurityConfig {
@Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
return http.csrf(ServerHttpSecurity.CsrfSpec::disable)
.cors(ServerHttpSecurity.CorsSpec::disable)
.authorizeExchange(authorizeExchangeSpec ->
authorizeExchangeSpec.pathMatchers("/internal/isReady", "/internal/isAlive", "/internal/metrics").permitAll()
.anyExchange().authenticated())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const createDefaultDate = () => {
const miljoeOptions = [
{ value: 'q1', label: 'Q1' },
{ value: 'q2', label: 'Q2' },
{ value: 'q1,q2', label: 'Q1+Q2' },
];

const AccessForm = () => {
Expand Down
6 changes: 6 additions & 0 deletions apps/organisasjon-tilgang-frontend/src/main/js/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@ code {

h1 {
text-align: center;
}

th {
text-align: center;
margin-left: 10px;
margin-right: 10px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,4 @@ private static ServerProperties forEnvironment(ServerProperties original, String
original.getUrl().replace("-MILJOE", replacement)
);
}

}
2 changes: 1 addition & 1 deletion proxies/dokarkiv-proxy/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ consumers:
name: dokarkiv-MILJOE
namespace: teamdokumenthandtering

environments: q1,q2,q4,q5
environments: q1,q2,q4

0 comments on commit a8b79bc

Please sign in to comment.