Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skal ikke kunne vurdere historiske delvilkår. Skal vise historiske de… #2939

Merged
merged 4 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const Aleneomsorg: React.FC<VilkårPropsMedBehandling> = ({
if (!vurdering) return null;

const erSisteBarn = indeks === grunnlag.barnMedSamvær.length - 1;

return (
<VilkårpanelInnhold
key={barn.barnId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import {
begrunnelseErPåkrevdOgUtfyllt,
erAlleDelvilkårBesvarte,
filtrerHistoriskeDelvilkår,
hentSvarsalternativ,
kanHaBegrunnelse,
kopierBegrunnelse,
Expand Down Expand Up @@ -48,7 +49,7 @@ const EndreVurderingComponent: FC<{
const { nullstillIkkePersistertKomponent, settIkkePersistertKomponent } = useApp();
const { settPanelITilstand } = useEkspanderbareVilkårpanelContext();
const [delvilkårsvurderinger, settDelvilkårsvurderinger] = useState<IDelvilkår[]>(
vurdering.delvilkårsvurderinger
filtrerHistoriskeDelvilkår(vurdering.delvilkårsvurderinger, regler)
);

const oppdaterVilkårsvar = (index: number, nySvarArray: Vurdering[]) => {
Expand Down Expand Up @@ -141,21 +142,22 @@ const EndreVurderingComponent: FC<{
});
}}
>
{delvilkårsvurderinger.map((delvikår, delvikårIndex) => {
return delvikår.vurderinger.map((svar) => {
{delvilkårsvurderinger.map((delvilkår, delvilkårIndex) => {
return delvilkår.vurderinger.map((svar) => {
const regel = regler[svar.regelId];

return (
<DelvilkårContainer key={regel.regelId}>
<Delvilkår
vurdering={svar}
regel={regel}
settVurdering={(nyVurdering) =>
oppdaterSvar(delvikår.vurderinger, delvikårIndex, nyVurdering)
oppdaterSvar(delvilkår.vurderinger, delvilkårIndex, nyVurdering)
}
/>
<Begrunnelse
onChange={(begrunnelse) =>
oppdaterBegrunnelse(delvikår.vurderinger, delvikårIndex, {
oppdaterBegrunnelse(delvilkår.vurderinger, delvilkårIndex, {
...svar,
begrunnelse,
})
Expand All @@ -175,4 +177,5 @@ const EndreVurderingComponent: FC<{
</form>
);
};

export default EndreVurderingComponent;
6 changes: 6 additions & 0 deletions src/frontend/Komponenter/Behandling/Vurdering/typer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ export interface Svarsalternativ {

export type SvarMapping = Record<SvarId, Svarsalternativ>;

export enum RegelVersjon {
GJELDENDE = 'GJELDENDE',
HISTORISK = 'HISTORISK',
}

export interface Regel {
regelId: string;
svarMapping: SvarMapping;
versjon: RegelVersjon;
}

export type Regler = {
Expand Down
20 changes: 19 additions & 1 deletion src/frontend/Komponenter/Behandling/Vurdering/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { Begrunnelse, BegrunnelseRegel, Regel, RegelId, Regler, Svarsalternativ } from './typer';
import {
Begrunnelse,
BegrunnelseRegel,
Regel,
RegelId,
RegelVersjon,
Regler,
Svarsalternativ,
} from './typer';
import { IDelvilkår, Vurdering } from '../Inngangsvilkår/vilkår';
import { harIkkeVerdi, harVerdi } from '../../../App/utils/utils';

Expand Down Expand Up @@ -79,6 +87,16 @@ export function erAlleDelvilkårBesvarte(
return erPåSisteNod && harBesvartAllePåkrevdeBegrunnelser;
}

export const filtrerHistoriskeDelvilkår = (
delvilkårListe: IDelvilkår[],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gjeldendeDelvilkår er kanskje mer presist navn her?

regler: Regler
): IDelvilkår[] =>
delvilkårListe.filter((delvilkår) =>
delvilkår.vurderinger.every(
(vurdering) => regler[vurdering.regelId].versjon === RegelVersjon.GJELDENDE
)
);

export function leggTilNesteIdHvis(
nesteRegelId: RegelId,
nySvarArray: Vurdering[],
Expand Down
Loading