Skip to content

Commit

Permalink
nullstill dokument-tilstand på load
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Anders Robbestad committed Feb 5, 2021
1 parent 66fd68d commit 7984cbb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions frontend/src/komponenter/Klagebehandling/Dokumenter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
hentDokumentSideHandling,
IKlage,
lasterDokumenter,
nullstillDokumenter,
} from "../../tilstand/moduler/klagebehandling";
import { useDispatch, useSelector } from "react-redux";
import { velgKlage } from "../../tilstand/moduler/klagebehandlinger.velgere";
Expand Down Expand Up @@ -30,7 +31,8 @@ function DokumentTabell(props: { settaktivtDokument: Function }) {
dispatch(hentDokumentSideHandling({ id: klage.id, ref: ref ?? null, antall: 10 }));
}
useEffect(() => {
hentNeste(null);
dispatch(nullstillDokumenter());
dispatch(hentDokumentSideHandling({ id: klage.id, ref: null, antall: 10 }));
}, []);

function hentForrige(ref: string | null) {
Expand Down Expand Up @@ -94,7 +96,7 @@ function DokumentTabell(props: { settaktivtDokument: Function }) {
<button
className={"knapp__lenke"}
onClick={() => hentForrige(klage.pageRefs[klage.pageIdx - 2])}
disabled={klage.pageIdx === 1}
disabled={klage.pageIdx === 0}
>
Forrige
</button>
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/tilstand/moduler/klagebehandling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ export const klageSlice = createSlice({
state.dokumenterLastet = action.payload;
return state;
},
NULLSTILL_DOKUMENTER: (state, action: PayloadAction<boolean>) => {
state.dokumenterLastet = false;
state.pageRefs = [];
state.pageIdx = 0;
return state;
},
DOKUMENTER_HENTET: (state, action: PayloadAction<IKlage>) => {
const { historyNavigate, historyRef } = action.payload;
state.dokumenterLastet = true;
Expand Down Expand Up @@ -144,6 +150,7 @@ export const hentDokumentSideHandling = createAction<Partial<IDokumentParams>>(
);

export const lasterDokumenter = createAction<boolean>("klagebehandling/LASTER_DOKUMENTER");
export const nullstillDokumenter = createAction("klagebehandling/NULLSTILL_DOKUMENTER");

//==========
// Epos
Expand Down

0 comments on commit 7984cbb

Please sign in to comment.