-
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.
Laget en hook for å hente IDer på vilkårsvurderinger som kan gjenbruk…
…es. Bruker hooken i BehandlingContext. Sjekker om en ID til en vilkårsvurdering finnes i listen for gjenbrukbare vilkår.
- Loading branch information
1 parent
1aa9a38
commit 85ae32d
Showing
5 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
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
36 changes: 36 additions & 0 deletions
36
src/frontend/App/hooks/useHentAlleGjenbrukbareVilkårsvurderinger.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,36 @@ | ||
import { useCallback, useState } from 'react'; | ||
import { RessursStatus } from '../typer/ressurs'; | ||
import { useApp } from '../context/AppContext'; | ||
|
||
interface Props { | ||
gjenbrukbareVilkårsvurderinger: string[]; | ||
hentAlleGjenbrukbareVilkårsvurderinger: (behandlingId: string) => Promise<void>; | ||
} | ||
|
||
export const useHentAlleGjenbrukbareVilkårsvurderinger = (): Props => { | ||
const [gjenbrukbareVilkårsvurderinger, settGjenbrukbareVilkårsvurderinger] = useState<string[]>( | ||
[] | ||
); | ||
|
||
const { axiosRequest } = useApp(); | ||
|
||
const hentAlleGjenbrukbareVilkårsvurderinger = useCallback( | ||
async (behandlingId: string): Promise<void> => { | ||
const respons = await axiosRequest<string[], void>({ | ||
method: 'GET', | ||
url: `/familie-ef-sak/api/vurdering/${behandlingId}/gjenbrukbare-vilkår`, | ||
}); | ||
if (respons.status === RessursStatus.SUKSESS) { | ||
settGjenbrukbareVilkårsvurderinger(respons.data); | ||
} else { | ||
settGjenbrukbareVilkårsvurderinger([]); | ||
} | ||
}, | ||
[axiosRequest] | ||
); | ||
|
||
return { | ||
gjenbrukbareVilkårsvurderinger, | ||
hentAlleGjenbrukbareVilkårsvurderinger, | ||
}; | ||
}; |
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
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
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