-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lagd en hook som henter en liste med grunnbeløpsperioder. Disse blir brukt for å sette seks G i frontend og Sanity.
- Loading branch information
1 parent
9139ed7
commit 14795a9
Showing
3 changed files
with
65 additions
and
18 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/frontend/App/hooks/felles/useHentGrunnbeløpsperioder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Ressurs } from '@navikt/familie-typer'; | ||
import { useCallback, useState } from 'react'; | ||
import { useApp } from '../../context/AppContext'; | ||
import { RessursStatus } from '../../typer/ressurs'; | ||
|
||
type GrunnbeløpData = { | ||
periode: { fom: string; tom: string }; | ||
grunnbeløp: number; | ||
grunnbeløpPerMåned: number; | ||
gjennomsnittPerÅr: number; | ||
seksGangerGrunnbeløp: number; | ||
seksGangerGrunnbeløpPerMåned: number; | ||
}; | ||
|
||
const tomGrunnbeløpsdata: GrunnbeløpData[] = []; | ||
|
||
export const useHentNyesteGrunnbeløpOgAntallGrunnbeløpsperioderTilbakeITid = (antall: number) => { | ||
const { axiosRequest } = useApp(); | ||
|
||
const [grunnbeløpsperioder, settGrunnbeløpsperioder] = | ||
useState<GrunnbeløpData[]>(tomGrunnbeløpsdata); | ||
|
||
const hentGrunnbeløpsperioderCallback = useCallback(() => { | ||
axiosRequest<GrunnbeløpData[], { antall: number }>({ | ||
method: 'GET', | ||
url: `/familie-ef-sak/api/beregning/grunnbelopForPerioder`, | ||
params: { antall }, | ||
}).then((res: Ressurs<GrunnbeløpData[]>) => { | ||
res.status === RessursStatus.SUKSESS && settGrunnbeløpsperioder(res.data); | ||
}); | ||
}, [axiosRequest, antall]); | ||
|
||
return { | ||
grunnbeløpsperioder, | ||
hentGrunnbeløpsperioderCallback, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 15 additions & 17 deletions
32
src/frontend/Komponenter/Behandling/Aktivitet/Inntekt/GrunnbeløpInfo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters