Skip to content

Commit 30ef5b6

Browse files
committed
Refactor bruk API_BASE_PATH for å kalle api fra klient (starter med '/')
1 parent 20f0dcd commit 30ef5b6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Aktiviteter/status-klient.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { StatusType } from "./AktivitetData";
2+
import {API_BASE_PATH} from "../utils/konstanter";
23

34
export const oppdaterStatus = async (
45
aktivitetId: string,
56
orgnr: string,
67
status: StatusType
78
) => {
89
return await fetch(
9-
`forebygge-fravar/api/aktivitet/${aktivitetId}/orgnr/${orgnr}/oppdater`,
10+
`${API_BASE_PATH}/aktivitet/${aktivitetId}/orgnr/${orgnr}/oppdater`,
1011
{
1112
method: "POST",
1213
body: JSON.stringify({ status }),

src/hooks/useHentAktiviteter.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useRestRessursSWR } from "./useRestRessursSWR";
2+
import {API_BASE_PATH} from "../utils/konstanter";
23

34
export type StatusType = "AVBRUTT" | "STARTET" | "FULLFØRT";
45
type AktivitetType = "OPPGAVE" | "AKTIVITETSKORT";
@@ -9,8 +10,10 @@ export type AktivitetBrukerStatus = {
910
};
1011

1112
export const useHentAktiviteter = (orgnr: string | null | undefined) => {
13+
const apiPath = `${API_BASE_PATH}/aktiviteter/orgnr/${orgnr}`;
14+
1215
return useRestRessursSWR<AktivitetBrukerStatus[]>(
13-
`forebygge-fravar/api/aktiviteter/orgnr/${orgnr}`,
16+
apiPath,
1417
"Det oppstod en feil ved henting av aktiviteter"
1518
);
1619
};

0 commit comments

Comments
 (0)