Skip to content

Commit

Permalink
fiks aapne paneler
Browse files Browse the repository at this point in the history
  • Loading branch information
poroshinaleksei committed Jan 16, 2025
1 parent 518b630 commit 428daef
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/app/søknader/pleiepenger/containers/PSBPunchForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,14 @@ export class PunchFormComponent extends React.Component<IPunchFormProps, IPunchF
soknad: new PSBSoknad(this.props.punchFormState.soknad as IPSBSoknad),
isFetched: true,
iTilsynsordning: !!this.props.punchFormState.soknad?.tilsynsordning?.perioder?.length,
aapnePaneler: this.getÅpnePanelerVedStart(this.props.punchFormState.soknad as IPSBSoknad),
});
if (!soknad.barn || !soknad.barn.norskIdent || soknad.barn.norskIdent === '') {
this.updateSoknad({ barn: { norskIdent: this.props.identState.pleietrengendeId || '' } });
}
}
// eslint-disable-next-line no-console
console.log('TEST Component did update aapnePaneler: ', this.state.aapnePaneler);
}

componentWillUnmount() {
Expand Down Expand Up @@ -280,6 +283,36 @@ export class PunchFormComponent extends React.Component<IPunchFormProps, IPunchF
});
};

private getÅpnePanelerVedStart = (soknad: Partial<IPSBSoknad>) => {
const åpnePaneler = new Set(this.state.aapnePaneler);
// eslint-disable-next-line no-console
console.log('TEST getÅpnePanelerVedStart');
const panelConditions = [
{ panel: PunchFormPaneler.UTENLANDSOPPHOLD, condition: soknad.utenlandsopphold?.length },
{ panel: PunchFormPaneler.FERIE, condition: soknad.lovbestemtFerie?.length },
{ panel: PunchFormPaneler.ARBEID, condition: soknad.arbeidstid?.arbeidstakerList?.length },
{ panel: PunchFormPaneler.ARBEID, condition: soknad.arbeidstid?.frilanserArbeidstidInfo },
{ panel: PunchFormPaneler.ARBEID, condition: soknad.opptjeningAktivitet?.selvstendigNaeringsdrivende },
{ panel: PunchFormPaneler.OPPLYSINGER_OM_SOKER, condition: soknad.omsorg?.relasjonTilBarnet },
{
panel: PunchFormPaneler.BEREDSKAPNATTEVAAK,
condition: soknad.beredskap?.length || soknad.nattevaak?.length,
},
{ panel: PunchFormPaneler.MEDLEMSKAP, condition: soknad.harMedisinskeOpplysninger },
];

panelConditions.forEach(({ panel, condition }) => {
if (condition && !åpnePaneler.has(panel)) {
// eslint-disable-next-line no-console
console.log('TEST getÅpnePanelerVedStart upd paneler');
åpnePaneler.add(panel);
}
});
// eslint-disable-next-line no-console
console.log('TEST getÅpnePanelerVedStart end');
return Array.from(åpnePaneler);
};

private checkOpenState = (p: PunchFormPaneler): boolean => {
const { aapnePaneler, expandAll } = this.state;
const hasInputErrors = this.props.punchFormState.inputErrors?.length;
Expand Down

0 comments on commit 428daef

Please sign in to comment.