-
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 lite med grunnbeløpsperioder. Disse blir b…
…rukt for å sette seks G.
- Loading branch information
1 parent
7ec540c
commit 80d49a8
Showing
3 changed files
with
64 additions
and
21 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/frontend/App/hooks/felles/useHentGrunbelø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øpOgAntallGrunnlø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