Skip to content

Commit

Permalink
Prosess vilkar overstyring v2 (#6756)
Browse files Browse the repository at this point in the history
* Laget v2-versjon av prosess-vilkar-overstyring

* Bort med react-intl
Fikset tester og stories

* Fiks av tester

* Bruker v2-panel for ungdomsytelse

* Sender ned vilkårstype slik at avslagsårsaker kan mappes

* Retter feil i tester

* Flyttet tester inn i stories

* Retter overskrift

* Fiks imports

* fiks css

* Legger til eksplisitt type istadenfor any.

* Bruker structuredClone fremfor JSON.stringify
Lager en delt komponent for OverstyrBekreftKnappPanel

* Tar bort duplisert kode

* Tar bort ubrukt kode

---------

Co-authored-by: Jostein Stuhaug <jostein.stuhaug@nav.no>
  • Loading branch information
hallvardastark and josstn authored Nov 19, 2024
1 parent e762506 commit 3c1a741
Show file tree
Hide file tree
Showing 76 changed files with 1,845 additions and 280 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@
]
},
"packageManager": "yarn@3.4.1"
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { ReactNode } from 'react';
import { ReactNode } from 'react';

import kodeverkTyper from '@fpsak-frontend/kodeverk/src/kodeverkTyper';
import VilkarresultatMedOverstyringProsessIndex from '@fpsak-frontend/prosess-vilkar-overstyring';

import { VilkarresultatMedOverstyringProsessIndex as VilkarresultatMedOverstyringProsessIndexV2 } from '@k9-sak-web/gui/prosess/vilkar-overstyring/VilkarresultatMedOverstyringProsessIndex.js';
import { ProsessStegPanelDef } from './ProsessStegDef';

const harVilkarresultatMedOverstyring = (aksjonspunkterForSteg, aksjonspunktDefKoderForSteg) => {
Expand Down Expand Up @@ -34,7 +34,12 @@ class ProsessStegOverstyringPanelDef extends ProsessStegPanelDef {
getOverstyrVisningAvKomponent = ({ vilkarForSteg, aksjonspunkterForSteg, aksjonspunktDefKoderForSteg }): boolean =>
vilkarForSteg.length > 0 && harVilkarresultatMedOverstyring(aksjonspunkterForSteg, aksjonspunktDefKoderForSteg);

getKomponent = (props): ReactNode => <VilkarresultatMedOverstyringProsessIndex {...props} />;
getKomponent = (props): ReactNode => {
if (props.usev2Panel) {
return <VilkarresultatMedOverstyringProsessIndexV2 {...props} />;
}
return <VilkarresultatMedOverstyringProsessIndex {...props} />;
};

getData = ({
vilkarForSteg,
Expand All @@ -45,17 +50,17 @@ class ProsessStegOverstyringPanelDef extends ProsessStegPanelDef {
kanOverstyreAccess,
toggleOverstyring,
}): any => ({
avslagsarsaker: alleKodeverk[kodeverkTyper.AVSLAGSARSAK][vilkarForSteg[0].vilkarType.kode],
erOverstyrt: overstyrteAksjonspunktKoder.some(o => this.getAksjonspunktKoder().some(a => a === o)),
overstyringApKode: this.getAksjonspunktKoder()[0],
panelTittelKode: this.getTekstKode() ? this.getTekstKode() : prosessStegTekstKode,
erMedlemskapsPanel: this.getId() === 'MEDLEMSKAP',
visPeriodisering: this.getId() === 'OMSORGENFOR',
lovReferanse: vilkarForSteg.length > 0 ? vilkarForSteg[0].lovReferanse : undefined,
overrideReadOnly,
kanOverstyreAccess,
toggleOverstyring,
});
avslagsarsaker: alleKodeverk[kodeverkTyper.AVSLAGSARSAK][vilkarForSteg[0].vilkarType.kode],
erOverstyrt: overstyrteAksjonspunktKoder.some(o => this.getAksjonspunktKoder().some(a => a === o)),
overstyringApKode: this.getAksjonspunktKoder()[0],
panelTittelKode: this.getTekstKode() ? this.getTekstKode() : prosessStegTekstKode,
erMedlemskapsPanel: this.getId() === 'MEDLEMSKAP',
visPeriodisering: this.getId() === 'OMSORGENFOR',
lovReferanse: vilkarForSteg.length > 0 ? vilkarForSteg[0].lovReferanse : undefined,
overrideReadOnly,
kanOverstyreAccess,
toggleOverstyring,
});
}

export default ProsessStegOverstyringPanelDef;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class BeregningFaktaPanelDef extends FaktaPanelDef {
getAksjonspunktKoder = () => [aksjonspunktCodes.VURDER_FAKTA_FOR_ATFL_SN];

getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps);
const bgVilkaret = deepCopyProps.vilkar.find(v => v.vilkarType === vilkarType.BEREGNINGSGRUNNLAGVILKARET);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React from 'react';

import vilkarType from '@fpsak-frontend/kodeverk/src/vilkarType';
import { prosessStegCodes } from '@k9-sak-web/konstanter';
import aksjonspunktCodes from '@fpsak-frontend/kodeverk/src/aksjonspunktCodes';
import { ProsessStegDef, ProsessStegPanelDef } from '@k9-sak-web/behandling-felles';
import vilkarType from '@fpsak-frontend/kodeverk/src/vilkarType';
import { konverterKodeverkTilKode, mapVilkar, transformBeregningValues } from '@fpsak-frontend/utils';
import { ProsessStegDef, ProsessStegPanelDef } from '@k9-sak-web/behandling-felles';
import { prosessStegCodes } from '@k9-sak-web/konstanter';
import { BeregningsgrunnlagProsessIndex } from '@navikt/ft-prosess-beregningsgrunnlag';

const mapYtelsesSpesifiktGrunnlagForFrisinn = (beregningsgrunnlag, behandling) =>
Expand All @@ -19,7 +17,7 @@ const mapYtelsesSpesifiktGrunnlagForFrisinn = (beregningsgrunnlag, behandling) =
class PanelDef extends ProsessStegPanelDef {
// eslint-disable-next-line class-methods-use-this
getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps);
const bgVilkaret = deepCopyProps.vilkar.find(v => v.vilkarType === vilkarType.BEREGNINGSGRUNNLAGVILKARET);
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const harKunAvslåtteUttak = beregningsresultatUtbetaling => {

class PanelDef extends ProsessStegPanelDef {
getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps, false);
return <TilkjentYtelseProsessIndex {...props} {...deepCopyProps} />;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class BeregningFaktaPanelDef extends FaktaPanelDef {
];

getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps);
const bgVilkaret = deepCopyProps.vilkar.find(v => v.vilkarType === vilkarType.BEREGNINGSGRUNNLAGVILKARET);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import aksjonspunktCodes from '@fpsak-frontend/kodeverk/src/aksjonspunktCodes';
import vilkarType from '@fpsak-frontend/kodeverk/src/vilkarType';
import { konverterKodeverkTilKode, transformBeregningValues } from '@fpsak-frontend/utils';
Expand All @@ -20,7 +18,7 @@ class FordelBeregningPanelDef extends FaktaPanelDef {
];

getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps);
const bgVilkaret = deepCopyProps.vilkar.find(v => v.vilkarType === vilkarType.BEREGNINGSGRUNNLAGVILKARET);
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import aksjonspunktCodes from '@fpsak-frontend/kodeverk/src/aksjonspunktCodes';
import vilkarType from '@fpsak-frontend/kodeverk/src/vilkarType';
import { konverterKodeverkTilKode, mapVilkar, transformBeregningValues } from '@fpsak-frontend/utils';
Expand All @@ -11,7 +9,7 @@ import '@navikt/ft-prosess-beregningsgrunnlag/dist/style.css';
class PanelDef extends ProsessStegPanelDef {
// eslint-disable-next-line class-methods-use-this
getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps);
const bgVilkaret = deepCopyProps.vilkar.find(v => v.vilkarType === vilkarType.BEREGNINGSGRUNNLAGVILKARET);
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const harKunAvslåtteUttak = beregningsresultatUtbetaling => {

class PanelDef extends ProsessStegPanelDef {
getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps, false);
return <TilkjentYtelseProsessIndex {...props} {...deepCopyProps} />;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SoknadsfristPanelDef extends ProsessStegPanelDef {
getTekstKode = () => 'Søknadsfrist';

getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps, false);
if (props.featureToggles?.PROSESS_VILKAR_SOKNADSFRIST) {
return <SoknadsfristVilkarProsessIndexV2 {...props} {...deepCopyProps} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class BeregningFaktaPanelDef extends FaktaPanelDef {

// eslint-disable-next-line class-methods-use-this
getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps);
const bgVilkaret = deepCopyProps.vilkar.find(v => v.vilkarType === vilkarType.BEREGNINGSGRUNNLAGVILKARET);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import aksjonspunktCodes from '@fpsak-frontend/kodeverk/src/aksjonspunktCodes';
import vilkarType from '@fpsak-frontend/kodeverk/src/vilkarType';
import { konverterKodeverkTilKode, transformBeregningValues } from '@fpsak-frontend/utils';
Expand All @@ -20,7 +18,7 @@ class FordelBeregningPanelDef extends FaktaPanelDef {
];

getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps);
const bgVilkaret = deepCopyProps.vilkar.find(v => v.vilkarType === vilkarType.BEREGNINGSGRUNNLAGVILKARET);
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import aksjonspunktCodes from '@fpsak-frontend/kodeverk/src/aksjonspunktCodes';
import vilkarType from '@fpsak-frontend/kodeverk/src/vilkarType';
import { konverterKodeverkTilKode, mapVilkar, transformBeregningValues } from '@fpsak-frontend/utils';
Expand All @@ -11,7 +9,7 @@ import '@navikt/ft-prosess-beregningsgrunnlag/dist/style.css';
class PanelDef extends ProsessStegPanelDef {
// eslint-disable-next-line class-methods-use-this
getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps);
const bgVilkaret = deepCopyProps.vilkar.find(v => v.vilkarType === vilkarType.BEREGNINGSGRUNNLAGVILKARET);
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const harKunAvslåtteUttak = beregningsresultatUtbetaling => {

class PanelDef extends ProsessStegPanelDef {
getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps, false);
return <TilkjentYtelseProsessIndex {...props} {...deepCopyProps} />;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SoknadsfristPanelDef extends ProsessStegPanelDef {
getTekstKode = () => 'Søknadsfrist';

getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps, false);
if (props.featureToggles?.PROSESS_VILKAR_SOKNADSFRIST) {
return <SoknadsfristVilkarProsessIndexV2 {...props} {...deepCopyProps} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class BeregningFaktaPanelDef extends FaktaPanelDef {
];

getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps);
const bgVilkaret = deepCopyProps.vilkar.find(v => v.vilkarType === vilkarType.BEREGNINGSGRUNNLAGVILKARET);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import aksjonspunktCodes from '@fpsak-frontend/kodeverk/src/aksjonspunktCodes';
import vilkarType from '@fpsak-frontend/kodeverk/src/vilkarType';
import { konverterKodeverkTilKode, transformBeregningValues } from '@fpsak-frontend/utils';
Expand All @@ -20,7 +18,7 @@ class FordelBeregningPanelDef extends FaktaPanelDef {
];

getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps);
const bgVilkaret = deepCopyProps.vilkar.find(v => v.vilkarType === vilkarType.BEREGNINGSGRUNNLAGVILKARET);
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import aksjonspunktCodes from '@fpsak-frontend/kodeverk/src/aksjonspunktCodes';
import vilkarType from '@fpsak-frontend/kodeverk/src/vilkarType';
import { konverterKodeverkTilKode, mapVilkar, transformBeregningValues } from '@fpsak-frontend/utils';
Expand All @@ -11,7 +9,7 @@ import '@navikt/ft-prosess-beregningsgrunnlag/dist/style.css';
class PanelDef extends ProsessStegPanelDef {
// eslint-disable-next-line class-methods-use-this
getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps);
const bgVilkaret = deepCopyProps.vilkar.find(v => v.vilkarType === vilkarType.BEREGNINGSGRUNNLAGVILKARET);
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const harKunAvslåtteUttak = beregningsresultatUtbetaling => {

class PanelDef extends ProsessStegPanelDef {
getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps, false);
return <TilkjentYtelseProsessIndex {...props} {...deepCopyProps} />;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SoknadsfristPanelDef extends ProsessStegPanelDef {
getTekstKode = () => 'Søknadsfrist';

getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps, false);
if (props.featureToggles?.PROSESS_VILKAR_SOKNADSFRIST) {
return <SoknadsfristVilkarProsessIndexV2 {...props} {...deepCopyProps} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class BeregningFaktaPanelDef extends FaktaPanelDef {

// eslint-disable-next-line class-methods-use-this
getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps);
const bgVilkaret = deepCopyProps.vilkar.find(v => v.vilkarType === vilkarType.BEREGNINGSGRUNNLAGVILKARET);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FordelBeregningPanelDef extends FaktaPanelDef {
];

getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps);
const bgVilkaret = deepCopyProps.vilkar.find(v => v.vilkarType === vilkarType.BEREGNINGSGRUNNLAGVILKARET);
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import aksjonspunktCodes from '@fpsak-frontend/kodeverk/src/aksjonspunktCodes';
import vilkarType from '@fpsak-frontend/kodeverk/src/vilkarType';
import { konverterKodeverkTilKode, mapVilkar, transformBeregningValues } from '@fpsak-frontend/utils';
Expand All @@ -11,7 +9,7 @@ import '@navikt/ft-prosess-beregningsgrunnlag/dist/style.css';
class PanelDef extends ProsessStegPanelDef {
// eslint-disable-next-line class-methods-use-this
getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps);
const bgVilkaret = deepCopyProps.vilkar.find(v => v.vilkarType === vilkarType.BEREGNINGSGRUNNLAGVILKARET);
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const harKunAvslåtteUttak = beregningsresultatUtbetaling => {

class PanelDef extends ProsessStegPanelDef {
getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps, false);
return <TilkjentYtelseProsessIndex {...props} {...deepCopyProps} />;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SoknadsfristPanelDef extends ProsessStegPanelDef {
getTekstKode = () => 'Søknadsfrist';

getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps, false);
if (props.featureToggles?.PROSESS_VILKAR_SOKNADSFRIST) {
return <SoknadsfristVilkarProsessIndexV2 {...props} {...deepCopyProps} />;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import React from 'react';

import vilkarUtfallType from '@fpsak-frontend/kodeverk/src/vilkarUtfallType';
import navBrukerKjonn from '@fpsak-frontend/kodeverk/src/navBrukerKjonn';
import { prosessStegCodes } from '@k9-sak-web/konstanter';
import aksjonspunktCodesTilbakekreving from '@fpsak-frontend/kodeverk/src/aksjonspunktCodesTilbakekreving';
import { getAlleMerknaderFraBeslutter, ProsessStegDef, ProsessStegPanelDef } from '@k9-sak-web/behandling-felles';
import navBrukerKjonn from '@fpsak-frontend/kodeverk/src/navBrukerKjonn';
import vilkarUtfallType from '@fpsak-frontend/kodeverk/src/vilkarUtfallType';
import { konverterKodeverkTilKode } from '@fpsak-frontend/utils';
import { getAlleMerknaderFraBeslutter, ProsessStegDef, ProsessStegPanelDef } from '@k9-sak-web/behandling-felles';
import { prosessStegCodes } from '@k9-sak-web/konstanter';
import ForeldelseProsessIndexWrapper from '../../components/ForeldelseProsessIndexWrapper';

class PanelDef extends ProsessStegPanelDef {
getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps, true);
return (
<ForeldelseProsessIndexWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const harKunAvslåtteUttak = beregningsresultatUtbetaling => {

class PanelDef extends ProsessStegPanelDef {
getKomponent = props => {
const deepCopyProps = JSON.parse(JSON.stringify(props));
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps, false);
return <TilkjentYtelseProsessIndex {...props} {...deepCopyProps} />;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import vilkarType from '@fpsak-frontend/kodeverk/src/vilkarType';
import { ProsessStegPanelDef, ProsessStegOverstyringPanelDef } from '@k9-sak-web/behandling-felles';
import { ProsessStegOverstyringPanelDef, ProsessStegPanelDef } from '@k9-sak-web/behandling-felles';
import { konverterKodeverkTilKode } from '@k9-sak-web/lib/kodeverk/konverterKodeverkTilKode.js';

class AlderPanelDef extends ProsessStegPanelDef {
overstyringDef = new ProsessStegOverstyringPanelDef(this);

getId = () => 'ALDER';

getTekstKode = () => 'Inngangsvilkar.Alder';
getTekstKode = () => 'Alder';

getKomponent = props => this.overstyringDef.getKomponent(props);
getKomponent = props => {
const deepCopyProps = structuredClone(props);
konverterKodeverkTilKode(deepCopyProps, false);
return this.overstyringDef.getKomponent({ ...props, ...deepCopyProps, usev2Panel: true });
};

getAksjonspunktKoder = () => [];

Expand Down
Loading

0 comments on commit 3c1a741

Please sign in to comment.