Skip to content

Commit

Permalink
Fiks loading av jp (#2828)
Browse files Browse the repository at this point in the history
* Fiks loading av jp

* Slettet default open param i  accordion paneler PSB form
  • Loading branch information
poroshinaleksei authored Jan 16, 2025
1 parent ad11817 commit 66355b9
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 69 deletions.
65 changes: 24 additions & 41 deletions cypress/fixtures/pleiepengerSoknadSomKanSendesInn.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,37 @@
{
"soeknadId": "0416e1a2-8d80-48b1-a56e-ab4f4b4821fe",
"soekerId": "29099000129",
"journalposter": ["200"],
"mottattDato": "2020-10-12",
"klokkeslett": "12:53",
"arbeidstid": null,
"barn": {
"norskIdent": "16017725002",
"foedselsdato": null
},
"begrunnelseForInnsending": null,
"beredskap": null,
"bosteder": null,
"harInfoSomIkkeKanPunsjes": false,
"harMedisinskeOpplysninger": false,
"journalposter": ["200"],
"k9saksnummer": "10002Fi",
"klokkeslett": "12:53",
"lovbestemtFerie": null,
"lovbestemtFerieSomSkalSlettes": null,
"metadata": null,
"mottattDato": "2024-10-12",
"nattevaak": null,
"omsorg": null,
"opptjeningAktivitet": null,
"soekerId": "29099000129",
"soeknadId": "0416e1a2-8d80-48b1-a56e-ab4f4b4821fe",
"soeknadsperiode": [
{
"fom": "2021-11-08",
"tom": "2021-11-11"
}
],
"opptjeningAktivitet": {
"selvstendigNaeringsdrivende": null,
"frilanser": null,
"arbeidstaker": []
},
"arbeidstid": {
"arbeidstakerList": [],
"frilanserArbeidstidInfo": null,
"selvstendigNæringsdrivendeArbeidstidInfo": {
"perioder": []
}
},
"beredskap": [],
"nattevaak": [],
"tilsynsordning": {
"perioder": []
},
"uttak": [],
"omsorg": {
"relasjonTilBarnet": "",
"samtykketOmsorgForBarnet": null,
"beskrivelseAvOmsorgsrollen": ""
},
"bosteder": [],
"lovbestemtFerie": [],
"lovbestemtFerieSomSkalSlettes": [],
"soknadsinfo": {
"samtidigHjemme": null,
"harMedsoeker": null
},
"utenlandsopphold": [],
"harInfoSomIkkeKanPunsjes": false,
"harMedisinskeOpplysninger": false,
"soknadsinfo": null,
"tilsynsordning": null,

"trekkKravPerioder": [],
"begrunnelseForInnsending": {
"tekst": ""
}
"utenlandsopphold": null,
"utenlandsoppholdV2": [],
"uttak": null
}
10 changes: 4 additions & 6 deletions src/app/containers/JournalpostLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ const JournalpostLoader: React.FC<Props> = ({ renderOnLoadComplete }: Props) =>
const [ingenJp, setIngenJp] = useState(false);

useEffect(() => {
if (journalpostid) {
if (!journalpost && journalpostid) {
getJournalpost(journalpostid);
}
}, [journalpostid]);
}, [journalpostid, journalpost]);

const handleLukkDebugg = () => {
if (journalpostid) {
Expand All @@ -66,10 +66,8 @@ const JournalpostLoader: React.FC<Props> = ({ renderOnLoadComplete }: Props) =>

if (isJournalpostLoading) {
return (
<div className="h-screen">
<div className="justify-content-center align-items-center h-screen flex flex-wrap">
<Loader size="large" data-testid="spinner" />
</div>
<div className="flex justify-center mt-40">
<Loader size="3xlarge" data-testid="spinner" />
</div>
);
}
Expand Down
15 changes: 9 additions & 6 deletions src/app/home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const Home: React.FC = () => {
journalpostConflict,
journalpostConflictError,
journalpostRequestError,
isJournalpostLoading,
} = useSelector((state: RootStateType) => state.felles);

const lukkOppgaveDone = useSelector((state: RootStateType) => state.fordelingState.lukkOppgaveDone);
Expand Down Expand Up @@ -83,11 +84,6 @@ export const Home: React.FC = () => {

useEffect(() => {
if (journalpost?.journalpostId) {
// Her har jeg lagt inn en reset av redux state fordi tidligere ble window.location.href brukt for å navigere til journalposten.
// så hvis man ikke resetter state først skjer det rare ting.
// TODO: fiks dette så vi slipper å kjøre kall for å hente ut journalpost to ganger
dispatch(resetAllStateAction());

navigate(ROUTES.JOURNALPOST_ROOT.replace(':journalpostid/*', journalpost.journalpostId));
}
}, [journalpost]);
Expand All @@ -110,10 +106,17 @@ export const Home: React.FC = () => {
onChange={onChange}
label={<FormattedMessage id="søk.label.jpid" />}
onKeyDown={handleKeydown}
disabled={isJournalpostLoading}
/>

<div className="ml-4">
<Button onClick={onClick} size="small" className="sokknapp my-4" disabled={!journalpostid}>
<Button
onClick={onClick}
size="small"
className="sokknapp my-4"
disabled={!journalpostid || isJournalpostLoading}
loading={isJournalpostLoading}
>
<FormattedMessage id={'søk.knapp.label'} />
</Button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,6 @@ const ArbeidsforholdPanel = ({
return (
<Accordion.Item
open={isOpen}
defaultOpen={isOpen}
onOpenChange={() => onPanelClick()}
data-testid="accordionItem-arbeidsforholdPanel"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ const EndringAvSøknadsperioder = (props: Props) => {

return (
<Accordion.Item
defaultOpen={isOpen}
open={isOpen}
className="endringAvSøknadsperioder"
onOpenChange={onClick}
Expand Down
13 changes: 1 addition & 12 deletions src/app/søknader/pleiepenger/containers/PSBPunchForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,6 @@ export class PunchFormComponent extends React.Component<IPunchFormProps, IPunchF
<VerticalSpacer sixteenPx />

<Accordion.Item
defaultOpen={this.checkOpenState(PunchFormPaneler.UTENLANDSOPPHOLD)}
open={this.checkOpenState(PunchFormPaneler.UTENLANDSOPPHOLD)}
onOpenChange={() => this.handlePanelClick(PunchFormPaneler.UTENLANDSOPPHOLD)}
data-testid="accordionItem-utenlandsoppholdpanel"
Expand Down Expand Up @@ -942,7 +941,6 @@ export class PunchFormComponent extends React.Component<IPunchFormProps, IPunchF

<Accordion.Item
open={this.checkOpenState(PunchFormPaneler.FERIE)}
defaultOpen={this.checkOpenState(PunchFormPaneler.FERIE)}
onOpenChange={() => this.handlePanelClick(PunchFormPaneler.FERIE)}
data-testid="accordionItem-feriepanel"
>
Expand All @@ -953,7 +951,6 @@ export class PunchFormComponent extends React.Component<IPunchFormProps, IPunchF
<Accordion.Content>
<CheckboksPanel
label={intlHelper(intl, 'skjema.ferie.leggtil')}
value="skjema.ferie.leggtil"
onChange={(e) => this.updateSkalHaFerie(e.target.checked)}
checked={!!soknad.lovbestemtFerie.length}
data-testid="feriepanel-checkbox"
Expand Down Expand Up @@ -982,7 +979,6 @@ export class PunchFormComponent extends React.Component<IPunchFormProps, IPunchF
<>
<CheckboksPanel
label={intlHelper(intl, 'skjema.ferie.fjern')}
value="skjema.ferie.fjern"
onChange={(e) => this.updateIkkeSkalHaFerie(e.target.checked)}
checked={!!soknad.lovbestemtFerieSomSkalSlettes.length}
/>
Expand Down Expand Up @@ -1032,7 +1028,6 @@ export class PunchFormComponent extends React.Component<IPunchFormProps, IPunchF

<Accordion.Item
open={this.checkOpenState(PunchFormPaneler.OPPLYSINGER_OM_SOKER)}
defaultOpen={this.checkOpenState(PunchFormPaneler.OPPLYSINGER_OM_SOKER)}
onOpenChange={() => this.handlePanelClick(PunchFormPaneler.OPPLYSINGER_OM_SOKER)}
data-testid="accordionItem-opplysningeromsokerpanel"
>
Expand Down Expand Up @@ -1069,7 +1064,6 @@ export class PunchFormComponent extends React.Component<IPunchFormProps, IPunchF

<Accordion.Item
open={this.checkOpenState(PunchFormPaneler.OMSORGSTILBUD)}
defaultOpen={this.checkOpenState(PunchFormPaneler.OMSORGSTILBUD)}
className={classNames('tilsynsordning')}
onOpenChange={() => this.handlePanelClick(PunchFormPaneler.OMSORGSTILBUD)}
data-testid="accordionItem-omsorgstilbudpanel"
Expand All @@ -1081,9 +1075,8 @@ export class PunchFormComponent extends React.Component<IPunchFormProps, IPunchF
<Accordion.Content>
<CheckboksPanel
label={intlHelper(intl, 'skjema.omsorgstilbud.checkboks')}
value="skjema.omsorgstilbud.checkboks"
onChange={(e) => this.updateOmsorgstilbud(e.target.checked)}
checked={this.state.iTilsynsordning}
checked={!!this.state.iTilsynsordning}
data-testid="omsorgstilbud-checkboks"
/>
{this.state.iTilsynsordning && (
Expand Down Expand Up @@ -1120,7 +1113,6 @@ export class PunchFormComponent extends React.Component<IPunchFormProps, IPunchF

<Accordion.Item
open={this.checkOpenState(PunchFormPaneler.BEREDSKAPNATTEVAAK)}
defaultOpen={this.checkOpenState(PunchFormPaneler.BEREDSKAPNATTEVAAK)}
onOpenChange={() => this.handlePanelClick(PunchFormPaneler.BEREDSKAPNATTEVAAK)}
data-testid="accordionItem-beredskapnattevaakpanel"
>
Expand All @@ -1131,7 +1123,6 @@ export class PunchFormComponent extends React.Component<IPunchFormProps, IPunchF
<Accordion.Content>
<CheckboksPanel
label={intlHelper(intl, BeredskapNattevaak.BEREDSKAP)}
value={BeredskapNattevaak.BEREDSKAP}
onChange={(e) =>
this.handleBeredskapNattevåkChange(BeredskapNattevaak.BEREDSKAP, e.target.checked)
}
Expand All @@ -1143,7 +1134,6 @@ export class PunchFormComponent extends React.Component<IPunchFormProps, IPunchF
<VerticalSpacer eightPx />
<CheckboksPanel
label={intlHelper(intl, BeredskapNattevaak.NATTEVAAK)}
value={BeredskapNattevaak.NATTEVAAK}
onChange={(e) =>
this.handleBeredskapNattevåkChange(BeredskapNattevaak.NATTEVAAK, e.target.checked)
}
Expand All @@ -1157,7 +1147,6 @@ export class PunchFormComponent extends React.Component<IPunchFormProps, IPunchF

<Accordion.Item
open={this.checkOpenState(PunchFormPaneler.MEDLEMSKAP)}
defaultOpen={this.checkOpenState(PunchFormPaneler.MEDLEMSKAP)}
onOpenChange={() => this.handlePanelClick(PunchFormPaneler.MEDLEMSKAP)}
data-testid="accordionItem-medlemskappanel"
>
Expand Down
7 changes: 5 additions & 2 deletions src/mocks/testHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import pilsSoknad from '../../cypress/fixtures/pilsSoknad.json';
import jpOMPUT314 from '../../cypress/fixtures/jpOMPUT314.json';

export const testHandlers = {
hentJournalpost: http.get(ApiPath.JOURNALPOST_GET.replace('{journalpostId}', ':id'), ({ params }) => {
hentJournalpost: http.get(ApiPath.JOURNALPOST_GET.replace('{journalpostId}', ':id'), async ({ params }) => {
await delay(500);

if (params.id === '300') {
return HttpResponse.json(jpPSB300, { status: 201 });
}
Expand Down Expand Up @@ -63,6 +65,7 @@ export const testHandlers = {
if (params.id === '206') {
return HttpResponse.json({ message: 'Forbidden' }, { status: 403 });
}

return HttpResponse.json({ ...journalpost, journalpostId: params.id });
}),
opprettePleiepengesoknad: http.post(ApiPath.PSB_SOKNAD_CREATE, () =>
Expand All @@ -88,7 +91,7 @@ export const testHandlers = {

eksisterendePleiepengesoknad: http.get(
ApiPath.PSB_SOKNAD_GET.replace('{id}', '0416e1a2-8d80-48b1-a56e-ab4f4b4821fe'),
() => HttpResponse.json(journalpost),
() => HttpResponse.json(pleiepengerSoknadSomKanSendesInn),
),
eksisterendePilssoknad: http.get(
ApiPath.PLS_SOKNAD_GET.replace('{id}', '4e3a9001-f872-4288-829e-08f8e1001b28'),
Expand Down

0 comments on commit 66355b9

Please sign in to comment.