diff --git a/orval.config.ts b/orval.config.ts index 13b603ba..c4bcee9c 100644 --- a/orval.config.ts +++ b/orval.config.ts @@ -10,6 +10,10 @@ export default { httpClient: "fetch", mock: true, override: { + mutator: { + path: "src/custom-fetch.ts", + name: "customFetch", + }, operations: { harTilgang: { fetch: { diff --git a/src/custom-fetch.ts b/src/custom-fetch.ts new file mode 100644 index 00000000..fef7893f --- /dev/null +++ b/src/custom-fetch.ts @@ -0,0 +1,15 @@ +export const customFetch = async (url: string, options: RequestInit): Promise => { + const response = await fetch(url, options); + if (response.status === 204) { + return [] as T; + } + const data: T = await response.json(); + + console.log("custom fetch url: ", url); + if (url.includes("harTilgang")) { + console.log("returnerer custom boio", {data, status: response.status}); + return {data, status: response.status} as T; + } + + return data as T; +}; diff --git a/src/generated/digisos-api-test-controller/digisos-api-test-controller.ts b/src/generated/digisos-api-test-controller/digisos-api-test-controller.ts index bbd3ffd0..38570557 100644 --- a/src/generated/digisos-api-test-controller/digisos-api-test-controller.ts +++ b/src/generated/digisos-api-test-controller/digisos-api-test-controller.ts @@ -18,6 +18,9 @@ import type { UseQueryResult, } from "@tanstack/react-query"; import type {FilOpplastingBody, OppdaterDigisosSakParams} from ".././model"; +import {customFetch} from "../../custom-fetch"; + +type SecondParameter any> = Parameters[1]; export const getFilOpplastingUrl = (fiksDigisosId: string) => { return `/sosialhjelp/innsyn/api/innsyn-api/api/v1/digisosapi/${fiksDigisosId}/filOpplasting`; @@ -31,14 +34,11 @@ export const filOpplasting = async ( const formData = new FormData(); formData.append("file", filOpplastingBody.file); - const res = await fetch(getFilOpplastingUrl(fiksDigisosId), { + return customFetch>(getFilOpplastingUrl(fiksDigisosId), { ...options, method: "POST", body: formData, }); - const data = await res.json(); - - return data as string; }; export const getFilOpplastingMutationOptions = (options?: { @@ -48,14 +48,14 @@ export const getFilOpplastingMutationOptions = ; - fetch?: RequestInit; + request?: SecondParameter; }): UseMutationOptions< Awaited>, TError, {fiksDigisosId: string; data: FilOpplastingBody}, TContext > => { - const {mutation: mutationOptions, fetch: fetchOptions} = options ?? {}; + const {mutation: mutationOptions, request: requestOptions} = options ?? {}; const mutationFn: MutationFunction< Awaited>, @@ -63,7 +63,7 @@ export const getFilOpplastingMutationOptions = = (props) => { const {fiksDigisosId, data} = props ?? {}; - return filOpplasting(fiksDigisosId, data, fetchOptions); + return filOpplasting(fiksDigisosId, data, requestOptions); }; return {mutationFn, ...mutationOptions}; @@ -80,7 +80,7 @@ export const useFilOpplasting = (options?: {fiksDigisosId: string; data: FilOpplastingBody}, TContext >; - fetch?: RequestInit; + request?: SecondParameter; }): UseMutationResult< Awaited>, TError, @@ -110,15 +110,12 @@ export const oppdaterDigisosSak = async ( params?: OppdaterDigisosSakParams, options?: RequestInit ): Promise => { - const res = await fetch(getOppdaterDigisosSakUrl(params), { + return customFetch>(getOppdaterDigisosSakUrl(params), { ...options, method: "POST", headers: {"Content-Type": "application/json", ...options?.headers}, body: JSON.stringify(oppdaterDigisosSakBody), }); - const data = await res.json(); - - return data as string; }; export const getOppdaterDigisosSakMutationOptions = (options?: { @@ -128,14 +125,14 @@ export const getOppdaterDigisosSakMutationOptions = ; - fetch?: RequestInit; + request?: SecondParameter; }): UseMutationOptions< Awaited>, TError, {data: string; params?: OppdaterDigisosSakParams}, TContext > => { - const {mutation: mutationOptions, fetch: fetchOptions} = options ?? {}; + const {mutation: mutationOptions, request: requestOptions} = options ?? {}; const mutationFn: MutationFunction< Awaited>, @@ -143,7 +140,7 @@ export const getOppdaterDigisosSakMutationOptions = = (props) => { const {data, params} = props ?? {}; - return oppdaterDigisosSak(data, params, fetchOptions); + return oppdaterDigisosSak(data, params, requestOptions); }; return {mutationFn, ...mutationOptions}; @@ -160,7 +157,7 @@ export const useOppdaterDigisosSak = (opti {data: string; params?: OppdaterDigisosSakParams}, TContext >; - fetch?: RequestInit; + request?: SecondParameter; }): UseMutationResult< Awaited>, TError, @@ -176,13 +173,10 @@ export const getGetInnsynsfilUrl = (digisosId: string) => { }; export const getInnsynsfil = async (digisosId: string, options?: RequestInit): Promise => { - const res = await fetch(getGetInnsynsfilUrl(digisosId), { + return customFetch>(getGetInnsynsfilUrl(digisosId), { ...options, method: "GET", }); - const data = await res.json(); - - return data as string; }; export const getGetInnsynsfilQueryKey = (digisosId: string) => { @@ -193,15 +187,15 @@ export const getGetInnsynsfilQueryOptions = >, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getGetInnsynsfilQueryKey(digisosId); const queryFn: QueryFunction>> = ({signal}) => - getInnsynsfil(digisosId, {signal, ...fetchOptions}); + getInnsynsfil(digisosId, {signal, ...requestOptions}); return {queryKey, queryFn, enabled: !!digisosId, ...queryOptions} as UseQueryOptions< Awaited>, @@ -218,7 +212,7 @@ export function useGetInnsynsfil>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; } ): DefinedUseQueryResult & {queryKey: QueryKey}; export function useGetInnsynsfil>, TError = unknown>( @@ -226,14 +220,14 @@ export function useGetInnsynsfil>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; export function useGetInnsynsfil>, TError = unknown>( digisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; @@ -241,7 +235,7 @@ export function useGetInnsynsfil>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getGetInnsynsfilQueryOptions(digisosId, options); diff --git a/src/generated/forelopig-svar-controller/forelopig-svar-controller.ts b/src/generated/forelopig-svar-controller/forelopig-svar-controller.ts index 7eb82370..05e19f0c 100644 --- a/src/generated/forelopig-svar-controller/forelopig-svar-controller.ts +++ b/src/generated/forelopig-svar-controller/forelopig-svar-controller.ts @@ -15,6 +15,9 @@ import type { UseQueryResult, } from "@tanstack/react-query"; import type {ForelopigSvarResponse} from ".././model"; +import {customFetch} from "../../custom-fetch"; + +type SecondParameter any> = Parameters[1]; export const getHentForelopigSvarStatusUrl = (fiksDigisosId: string) => { return `/sosialhjelp/innsyn/api/innsyn-api/api/v1/innsyn/${fiksDigisosId}/forelopigSvar`; @@ -24,13 +27,10 @@ export const hentForelopigSvarStatus = async ( fiksDigisosId: string, options?: RequestInit ): Promise => { - const res = await fetch(getHentForelopigSvarStatusUrl(fiksDigisosId), { + return customFetch>(getHentForelopigSvarStatusUrl(fiksDigisosId), { ...options, method: "GET", }); - const data = await res.json(); - - return data as ForelopigSvarResponse; }; export const getHentForelopigSvarStatusQueryKey = (fiksDigisosId: string) => { @@ -44,15 +44,15 @@ export const getHentForelopigSvarStatusQueryOptions = < fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getHentForelopigSvarStatusQueryKey(fiksDigisosId); const queryFn: QueryFunction>> = ({signal}) => - hentForelopigSvarStatus(fiksDigisosId, {signal, ...fetchOptions}); + hentForelopigSvarStatus(fiksDigisosId, {signal, ...requestOptions}); return {queryKey, queryFn, enabled: !!fiksDigisosId, ...queryOptions} as UseQueryOptions< Awaited>, @@ -75,7 +75,7 @@ export function useHentForelopigSvarStatus< DefinedInitialDataOptions>, TError, TData>, "initialData" >; - fetch?: RequestInit; + request?: SecondParameter; } ): DefinedUseQueryResult & {queryKey: QueryKey}; export function useHentForelopigSvarStatus< @@ -89,7 +89,7 @@ export function useHentForelopigSvarStatus< UndefinedInitialDataOptions>, TError, TData>, "initialData" >; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; export function useHentForelopigSvarStatus< @@ -99,7 +99,7 @@ export function useHentForelopigSvarStatus< fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; @@ -110,7 +110,7 @@ export function useHentForelopigSvarStatus< fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getHentForelopigSvarStatusQueryOptions(fiksDigisosId, options); diff --git a/src/generated/hendelse-controller/hendelse-controller.ts b/src/generated/hendelse-controller/hendelse-controller.ts index 72fa0bcf..c8b9887a 100644 --- a/src/generated/hendelse-controller/hendelse-controller.ts +++ b/src/generated/hendelse-controller/hendelse-controller.ts @@ -15,19 +15,19 @@ import type { UseQueryResult, } from "@tanstack/react-query"; import type {HendelseResponse} from ".././model"; +import {customFetch} from "../../custom-fetch"; + +type SecondParameter any> = Parameters[1]; export const getHentHendelserUrl = (fiksDigisosId: string) => { return `/sosialhjelp/innsyn/api/innsyn-api/api/v1/innsyn/${fiksDigisosId}/hendelser`; }; export const hentHendelser = async (fiksDigisosId: string, options?: RequestInit): Promise => { - const res = await fetch(getHentHendelserUrl(fiksDigisosId), { + return customFetch>(getHentHendelserUrl(fiksDigisosId), { ...options, method: "GET", }); - const data = await res.json(); - - return data as HendelseResponse[]; }; export const getHentHendelserQueryKey = (fiksDigisosId: string) => { @@ -38,15 +38,15 @@ export const getHentHendelserQueryOptions = >, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getHentHendelserQueryKey(fiksDigisosId); const queryFn: QueryFunction>> = ({signal}) => - hentHendelser(fiksDigisosId, {signal, ...fetchOptions}); + hentHendelser(fiksDigisosId, {signal, ...requestOptions}); return {queryKey, queryFn, enabled: !!fiksDigisosId, ...queryOptions} as UseQueryOptions< Awaited>, @@ -63,7 +63,7 @@ export function useHentHendelser>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; } ): DefinedUseQueryResult & {queryKey: QueryKey}; export function useHentHendelser>, TError = unknown>( @@ -71,14 +71,14 @@ export function useHentHendelser>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; export function useHentHendelser>, TError = unknown>( fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; @@ -86,7 +86,7 @@ export function useHentHendelser>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getHentHendelserQueryOptions(fiksDigisosId, options); diff --git a/src/generated/info-controller/info-controller.ts b/src/generated/info-controller/info-controller.ts index 9ce7ae32..551edaa3 100644 --- a/src/generated/info-controller/info-controller.ts +++ b/src/generated/info-controller/info-controller.ts @@ -7,33 +7,33 @@ import {useMutation} from "@tanstack/react-query"; import type {MutationFunction, UseMutationOptions, UseMutationResult} from "@tanstack/react-query"; import type {Logg} from ".././model"; +import {customFetch} from "../../custom-fetch"; + +type SecondParameter any> = Parameters[1]; export const getPostKlientloggUrl = () => { return `/sosialhjelp/innsyn/api/innsyn-api/api/v1/info/logg`; }; export const postKlientlogg = async (logg: Logg, options?: RequestInit): Promise => { - const res = await fetch(getPostKlientloggUrl(), { + return customFetch>(getPostKlientloggUrl(), { ...options, method: "POST", headers: {"Content-Type": "application/json", ...options?.headers}, body: JSON.stringify(logg), }); - const data = await res.json(); - - return data as void; }; export const getPostKlientloggMutationOptions = (options?: { mutation?: UseMutationOptions>, TError, {data: Logg}, TContext>; - fetch?: RequestInit; + request?: SecondParameter; }): UseMutationOptions>, TError, {data: Logg}, TContext> => { - const {mutation: mutationOptions, fetch: fetchOptions} = options ?? {}; + const {mutation: mutationOptions, request: requestOptions} = options ?? {}; const mutationFn: MutationFunction>, {data: Logg}> = (props) => { const {data} = props ?? {}; - return postKlientlogg(data, fetchOptions); + return postKlientlogg(data, requestOptions); }; return {mutationFn, ...mutationOptions}; @@ -45,7 +45,7 @@ export type PostKlientloggMutationError = unknown; export const usePostKlientlogg = (options?: { mutation?: UseMutationOptions>, TError, {data: Logg}, TContext>; - fetch?: RequestInit; + request?: SecondParameter; }): UseMutationResult>, TError, {data: Logg}, TContext> => { const mutationOptions = getPostKlientloggMutationOptions(options); diff --git a/src/generated/klage-controller/klage-controller.ts b/src/generated/klage-controller/klage-controller.ts index a598f67f..55f2d00d 100644 --- a/src/generated/klage-controller/klage-controller.ts +++ b/src/generated/klage-controller/klage-controller.ts @@ -18,19 +18,19 @@ import type { UseQueryResult, } from "@tanstack/react-query"; import type {InputKlage, KlageDto, Unit} from ".././model"; +import {customFetch} from "../../custom-fetch"; + +type SecondParameter any> = Parameters[1]; export const getHentKlagerUrl = (fiksDigisosId: string) => { return `/sosialhjelp/innsyn/api/innsyn-api/api/v1/innsyn/${fiksDigisosId}/klage`; }; export const hentKlager = async (fiksDigisosId: string, options?: RequestInit): Promise => { - const res = await fetch(getHentKlagerUrl(fiksDigisosId), { + return customFetch>(getHentKlagerUrl(fiksDigisosId), { ...options, method: "GET", }); - const data = await res.json(); - - return data as KlageDto[]; }; export const getHentKlagerQueryKey = (fiksDigisosId: string) => { @@ -41,15 +41,15 @@ export const getHentKlagerQueryOptions = >, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getHentKlagerQueryKey(fiksDigisosId); const queryFn: QueryFunction>> = ({signal}) => - hentKlager(fiksDigisosId, {signal, ...fetchOptions}); + hentKlager(fiksDigisosId, {signal, ...requestOptions}); return {queryKey, queryFn, enabled: !!fiksDigisosId, ...queryOptions} as UseQueryOptions< Awaited>, @@ -66,7 +66,7 @@ export function useHentKlager>, TE options: { query: Partial>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; } ): DefinedUseQueryResult & {queryKey: QueryKey}; export function useHentKlager>, TError = unknown>( @@ -74,14 +74,14 @@ export function useHentKlager>, TE options?: { query?: Partial>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; export function useHentKlager>, TError = unknown>( fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; @@ -89,7 +89,7 @@ export function useHentKlager>, TE fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getHentKlagerQueryOptions(fiksDigisosId, options); @@ -110,15 +110,12 @@ export const sendKlage = async ( inputKlage: InputKlage, options?: RequestInit ): Promise => { - const res = await fetch(getSendKlageUrl(fiksDigisosId), { + return customFetch>(getSendKlageUrl(fiksDigisosId), { ...options, method: "POST", headers: {"Content-Type": "application/json;charset=UTF-8", ...options?.headers}, body: JSON.stringify(inputKlage), }); - const data = await res.json(); - - return data as Unit; }; export const getSendKlageMutationOptions = (options?: { @@ -128,14 +125,14 @@ export const getSendKlageMutationOptions = ; - fetch?: RequestInit; + request?: SecondParameter; }): UseMutationOptions< Awaited>, TError, {fiksDigisosId: string; data: InputKlage}, TContext > => { - const {mutation: mutationOptions, fetch: fetchOptions} = options ?? {}; + const {mutation: mutationOptions, request: requestOptions} = options ?? {}; const mutationFn: MutationFunction< Awaited>, @@ -143,7 +140,7 @@ export const getSendKlageMutationOptions = = (props) => { const {fiksDigisosId, data} = props ?? {}; - return sendKlage(fiksDigisosId, data, fetchOptions); + return sendKlage(fiksDigisosId, data, requestOptions); }; return {mutationFn, ...mutationOptions}; @@ -160,7 +157,7 @@ export const useSendKlage = (options?: { {fiksDigisosId: string; data: InputKlage}, TContext >; - fetch?: RequestInit; + request?: SecondParameter; }): UseMutationResult< Awaited>, TError, diff --git a/src/generated/kommune-controller/kommune-controller.ts b/src/generated/kommune-controller/kommune-controller.ts index 6f54fe64..65fe3ef5 100644 --- a/src/generated/kommune-controller/kommune-controller.ts +++ b/src/generated/kommune-controller/kommune-controller.ts @@ -15,19 +15,19 @@ import type { UseQueryResult, } from "@tanstack/react-query"; import type {KommuneResponse} from ".././model"; +import {customFetch} from "../../custom-fetch"; + +type SecondParameter any> = Parameters[1]; export const getHentKommuneInfoUrl = (fiksDigisosId: string) => { return `/sosialhjelp/innsyn/api/innsyn-api/api/v1/innsyn/${fiksDigisosId}/kommune`; }; export const hentKommuneInfo = async (fiksDigisosId: string, options?: RequestInit): Promise => { - const res = await fetch(getHentKommuneInfoUrl(fiksDigisosId), { + return customFetch>(getHentKommuneInfoUrl(fiksDigisosId), { ...options, method: "GET", }); - const data = await res.json(); - - return data as KommuneResponse; }; export const getHentKommuneInfoQueryKey = (fiksDigisosId: string) => { @@ -38,15 +38,15 @@ export const getHentKommuneInfoQueryOptions = >, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getHentKommuneInfoQueryKey(fiksDigisosId); const queryFn: QueryFunction>> = ({signal}) => - hentKommuneInfo(fiksDigisosId, {signal, ...fetchOptions}); + hentKommuneInfo(fiksDigisosId, {signal, ...requestOptions}); return {queryKey, queryFn, enabled: !!fiksDigisosId, ...queryOptions} as UseQueryOptions< Awaited>, @@ -63,7 +63,7 @@ export function useHentKommuneInfo>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; } ): DefinedUseQueryResult & {queryKey: QueryKey}; export function useHentKommuneInfo>, TError = unknown>( @@ -74,14 +74,14 @@ export function useHentKommuneInfo>, TError, TData>, "initialData" >; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; export function useHentKommuneInfo>, TError = unknown>( fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; @@ -89,7 +89,7 @@ export function useHentKommuneInfo>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getHentKommuneInfoQueryOptions(fiksDigisosId, options); diff --git a/src/generated/oppgave-controller/oppgave-controller.ts b/src/generated/oppgave-controller/oppgave-controller.ts index 83995f46..e3827f0e 100644 --- a/src/generated/oppgave-controller/oppgave-controller.ts +++ b/src/generated/oppgave-controller/oppgave-controller.ts @@ -15,19 +15,19 @@ import type { UseQueryResult, } from "@tanstack/react-query"; import type {DokumentasjonkravResponse, OppgaveResponse, VilkarResponse} from ".././model"; +import {customFetch} from "../../custom-fetch"; + +type SecondParameter any> = Parameters[1]; export const getGetVilkarUrl = (fiksDigisosId: string) => { return `/sosialhjelp/innsyn/api/innsyn-api/api/v1/innsyn/${fiksDigisosId}/vilkar`; }; export const getVilkar = async (fiksDigisosId: string, options?: RequestInit): Promise => { - const res = await fetch(getGetVilkarUrl(fiksDigisosId), { + return customFetch>(getGetVilkarUrl(fiksDigisosId), { ...options, method: "GET", }); - const data = await res.json(); - - return data as VilkarResponse[]; }; export const getGetVilkarQueryKey = (fiksDigisosId: string) => { @@ -38,15 +38,15 @@ export const getGetVilkarQueryOptions = >, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getGetVilkarQueryKey(fiksDigisosId); const queryFn: QueryFunction>> = ({signal}) => - getVilkar(fiksDigisosId, {signal, ...fetchOptions}); + getVilkar(fiksDigisosId, {signal, ...requestOptions}); return {queryKey, queryFn, enabled: !!fiksDigisosId, ...queryOptions} as UseQueryOptions< Awaited>, @@ -63,7 +63,7 @@ export function useGetVilkar>, TErr options: { query: Partial>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; } ): DefinedUseQueryResult & {queryKey: QueryKey}; export function useGetVilkar>, TError = unknown>( @@ -71,14 +71,14 @@ export function useGetVilkar>, TErr options?: { query?: Partial>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; export function useGetVilkar>, TError = unknown>( fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; @@ -86,7 +86,7 @@ export function useGetVilkar>, TErr fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getGetVilkarQueryOptions(fiksDigisosId, options); @@ -103,13 +103,10 @@ export const getGetOppgaverUrl = (fiksDigisosId: string) => { }; export const getOppgaver = async (fiksDigisosId: string, options?: RequestInit): Promise => { - const res = await fetch(getGetOppgaverUrl(fiksDigisosId), { + return customFetch>(getGetOppgaverUrl(fiksDigisosId), { ...options, method: "GET", }); - const data = await res.json(); - - return data as OppgaveResponse[]; }; export const getGetOppgaverQueryKey = (fiksDigisosId: string) => { @@ -120,15 +117,15 @@ export const getGetOppgaverQueryOptions = >, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getGetOppgaverQueryKey(fiksDigisosId); const queryFn: QueryFunction>> = ({signal}) => - getOppgaver(fiksDigisosId, {signal, ...fetchOptions}); + getOppgaver(fiksDigisosId, {signal, ...requestOptions}); return {queryKey, queryFn, enabled: !!fiksDigisosId, ...queryOptions} as UseQueryOptions< Awaited>, @@ -145,7 +142,7 @@ export function useGetOppgaver>, options: { query: Partial>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; } ): DefinedUseQueryResult & {queryKey: QueryKey}; export function useGetOppgaver>, TError = unknown>( @@ -153,14 +150,14 @@ export function useGetOppgaver>, options?: { query?: Partial>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; export function useGetOppgaver>, TError = unknown>( fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; @@ -168,7 +165,7 @@ export function useGetOppgaver>, fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getGetOppgaverQueryOptions(fiksDigisosId, options); @@ -189,13 +186,10 @@ export const getOppgaveMedId = async ( oppgaveId: string, options?: RequestInit ): Promise => { - const res = await fetch(getGetOppgaveMedIdUrl(fiksDigisosId, oppgaveId), { + return customFetch>(getGetOppgaveMedIdUrl(fiksDigisosId, oppgaveId), { ...options, method: "GET", }); - const data = await res.json(); - - return data as OppgaveResponse[]; }; export const getGetOppgaveMedIdQueryKey = (fiksDigisosId: string, oppgaveId: string) => { @@ -207,15 +201,15 @@ export const getGetOppgaveMedIdQueryOptions = >, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getGetOppgaveMedIdQueryKey(fiksDigisosId, oppgaveId); const queryFn: QueryFunction>> = ({signal}) => - getOppgaveMedId(fiksDigisosId, oppgaveId, {signal, ...fetchOptions}); + getOppgaveMedId(fiksDigisosId, oppgaveId, {signal, ...requestOptions}); return {queryKey, queryFn, enabled: !!(fiksDigisosId && oppgaveId), ...queryOptions} as UseQueryOptions< Awaited>, @@ -233,7 +227,7 @@ export function useGetOppgaveMedId>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; } ): DefinedUseQueryResult & {queryKey: QueryKey}; export function useGetOppgaveMedId>, TError = unknown>( @@ -245,7 +239,7 @@ export function useGetOppgaveMedId>, TError, TData>, "initialData" >; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; export function useGetOppgaveMedId>, TError = unknown>( @@ -253,7 +247,7 @@ export function useGetOppgaveMedId>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; @@ -262,7 +256,7 @@ export function useGetOppgaveMedId>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getGetOppgaveMedIdQueryOptions(fiksDigisosId, oppgaveId, options); @@ -279,13 +273,10 @@ export const getGetHarLevertDokumentasjonkravUrl = (fiksDigisosId: string) => { }; export const getHarLevertDokumentasjonkrav = async (fiksDigisosId: string, options?: RequestInit): Promise => { - const res = await fetch(getGetHarLevertDokumentasjonkravUrl(fiksDigisosId), { + return customFetch>(getGetHarLevertDokumentasjonkravUrl(fiksDigisosId), { ...options, method: "GET", }); - const data = await res.json(); - - return data as boolean; }; export const getGetHarLevertDokumentasjonkravQueryKey = (fiksDigisosId: string) => { @@ -299,15 +290,15 @@ export const getGetHarLevertDokumentasjonkravQueryOptions = < fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getGetHarLevertDokumentasjonkravQueryKey(fiksDigisosId); const queryFn: QueryFunction>> = ({signal}) => - getHarLevertDokumentasjonkrav(fiksDigisosId, {signal, ...fetchOptions}); + getHarLevertDokumentasjonkrav(fiksDigisosId, {signal, ...requestOptions}); return {queryKey, queryFn, enabled: !!fiksDigisosId, ...queryOptions} as UseQueryOptions< Awaited>, @@ -332,7 +323,7 @@ export function useGetHarLevertDokumentasjonkrav< DefinedInitialDataOptions>, TError, TData>, "initialData" >; - fetch?: RequestInit; + request?: SecondParameter; } ): DefinedUseQueryResult & {queryKey: QueryKey}; export function useGetHarLevertDokumentasjonkrav< @@ -346,7 +337,7 @@ export function useGetHarLevertDokumentasjonkrav< UndefinedInitialDataOptions>, TError, TData>, "initialData" >; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; export function useGetHarLevertDokumentasjonkrav< @@ -356,7 +347,7 @@ export function useGetHarLevertDokumentasjonkrav< fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; @@ -367,7 +358,7 @@ export function useGetHarLevertDokumentasjonkrav< fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getGetHarLevertDokumentasjonkravQueryOptions(fiksDigisosId, options); @@ -387,13 +378,10 @@ export const getfagsystemHarDokumentasjonkrav = async ( fiksDigisosId: string, options?: RequestInit ): Promise => { - const res = await fetch(getGetfagsystemHarDokumentasjonkravUrl(fiksDigisosId), { + return customFetch>(getGetfagsystemHarDokumentasjonkravUrl(fiksDigisosId), { ...options, method: "GET", }); - const data = await res.json(); - - return data as boolean; }; export const getGetfagsystemHarDokumentasjonkravQueryKey = (fiksDigisosId: string) => { @@ -407,15 +395,15 @@ export const getGetfagsystemHarDokumentasjonkravQueryOptions = < fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getGetfagsystemHarDokumentasjonkravQueryKey(fiksDigisosId); const queryFn: QueryFunction>> = ({signal}) => - getfagsystemHarDokumentasjonkrav(fiksDigisosId, {signal, ...fetchOptions}); + getfagsystemHarDokumentasjonkrav(fiksDigisosId, {signal, ...requestOptions}); return {queryKey, queryFn, enabled: !!fiksDigisosId, ...queryOptions} as UseQueryOptions< Awaited>, @@ -440,7 +428,7 @@ export function useGetfagsystemHarDokumentasjonkrav< DefinedInitialDataOptions>, TError, TData>, "initialData" >; - fetch?: RequestInit; + request?: SecondParameter; } ): DefinedUseQueryResult & {queryKey: QueryKey}; export function useGetfagsystemHarDokumentasjonkrav< @@ -458,7 +446,7 @@ export function useGetfagsystemHarDokumentasjonkrav< >, "initialData" >; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; export function useGetfagsystemHarDokumentasjonkrav< @@ -468,7 +456,7 @@ export function useGetfagsystemHarDokumentasjonkrav< fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; @@ -479,7 +467,7 @@ export function useGetfagsystemHarDokumentasjonkrav< fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getGetfagsystemHarDokumentasjonkravQueryOptions(fiksDigisosId, options); @@ -499,13 +487,10 @@ export const getDokumentasjonkrav = async ( fiksDigisosId: string, options?: RequestInit ): Promise => { - const res = await fetch(getGetDokumentasjonkravUrl(fiksDigisosId), { + return customFetch>(getGetDokumentasjonkravUrl(fiksDigisosId), { ...options, method: "GET", }); - const data = await res.json(); - - return data as DokumentasjonkravResponse[]; }; export const getGetDokumentasjonkravQueryKey = (fiksDigisosId: string) => { @@ -519,15 +504,15 @@ export const getGetDokumentasjonkravQueryOptions = < fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getGetDokumentasjonkravQueryKey(fiksDigisosId); const queryFn: QueryFunction>> = ({signal}) => - getDokumentasjonkrav(fiksDigisosId, {signal, ...fetchOptions}); + getDokumentasjonkrav(fiksDigisosId, {signal, ...requestOptions}); return {queryKey, queryFn, enabled: !!fiksDigisosId, ...queryOptions} as UseQueryOptions< Awaited>, @@ -547,7 +532,7 @@ export function useGetDokumentasjonkrav>, TError, TData>, "initialData" >; - fetch?: RequestInit; + request?: SecondParameter; } ): DefinedUseQueryResult & {queryKey: QueryKey}; export function useGetDokumentasjonkrav>, TError = unknown>( @@ -558,14 +543,14 @@ export function useGetDokumentasjonkrav>, TError, TData>, "initialData" >; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; export function useGetDokumentasjonkrav>, TError = unknown>( fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; @@ -573,7 +558,7 @@ export function useGetDokumentasjonkrav>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getGetDokumentasjonkravQueryOptions(fiksDigisosId, options); @@ -594,13 +579,13 @@ export const getDokumentasjonkravMedId = async ( dokumentasjonkravId: string, options?: RequestInit ): Promise => { - const res = await fetch(getGetDokumentasjonkravMedIdUrl(fiksDigisosId, dokumentasjonkravId), { - ...options, - method: "GET", - }); - const data = await res.json(); - - return data as DokumentasjonkravResponse[]; + return customFetch>( + getGetDokumentasjonkravMedIdUrl(fiksDigisosId, dokumentasjonkravId), + { + ...options, + method: "GET", + } + ); }; export const getGetDokumentasjonkravMedIdQueryKey = (fiksDigisosId: string, dokumentasjonkravId: string) => { @@ -617,15 +602,15 @@ export const getGetDokumentasjonkravMedIdQueryOptions = < dokumentasjonkravId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getGetDokumentasjonkravMedIdQueryKey(fiksDigisosId, dokumentasjonkravId); const queryFn: QueryFunction>> = ({signal}) => - getDokumentasjonkravMedId(fiksDigisosId, dokumentasjonkravId, {signal, ...fetchOptions}); + getDokumentasjonkravMedId(fiksDigisosId, dokumentasjonkravId, {signal, ...requestOptions}); return {queryKey, queryFn, enabled: !!(fiksDigisosId && dokumentasjonkravId), ...queryOptions} as UseQueryOptions< Awaited>, @@ -649,7 +634,7 @@ export function useGetDokumentasjonkravMedId< DefinedInitialDataOptions>, TError, TData>, "initialData" >; - fetch?: RequestInit; + request?: SecondParameter; } ): DefinedUseQueryResult & {queryKey: QueryKey}; export function useGetDokumentasjonkravMedId< @@ -664,7 +649,7 @@ export function useGetDokumentasjonkravMedId< UndefinedInitialDataOptions>, TError, TData>, "initialData" >; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; export function useGetDokumentasjonkravMedId< @@ -675,7 +660,7 @@ export function useGetDokumentasjonkravMedId< dokumentasjonkravId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; @@ -687,7 +672,7 @@ export function useGetDokumentasjonkravMedId< dokumentasjonkravId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getGetDokumentasjonkravMedIdQueryOptions(fiksDigisosId, dokumentasjonkravId, options); diff --git a/src/generated/saks-oversikt-controller/saks-oversikt-controller.ts b/src/generated/saks-oversikt-controller/saks-oversikt-controller.ts index 20e92f36..5678d425 100644 --- a/src/generated/saks-oversikt-controller/saks-oversikt-controller.ts +++ b/src/generated/saks-oversikt-controller/saks-oversikt-controller.ts @@ -15,6 +15,9 @@ import type { UseQueryResult, } from "@tanstack/react-query"; import type {HentSaksDetaljerParams, SaksDetaljerResponse, SaksListeResponse} from ".././model"; +import {customFetch} from "../../custom-fetch"; + +type SecondParameter any> = Parameters[1]; export const getHentSaksDetaljerUrl = (params: HentSaksDetaljerParams) => { const normalizedParams = new URLSearchParams(); @@ -34,13 +37,10 @@ export const hentSaksDetaljer = async ( params: HentSaksDetaljerParams, options?: RequestInit ): Promise => { - const res = await fetch(getHentSaksDetaljerUrl(params), { + return customFetch>(getHentSaksDetaljerUrl(params), { ...options, method: "GET", }); - const data = await res.json(); - - return data as SaksDetaljerResponse; }; export const getHentSaksDetaljerQueryKey = (params: HentSaksDetaljerParams) => { @@ -51,15 +51,15 @@ export const getHentSaksDetaljerQueryOptions = >, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getHentSaksDetaljerQueryKey(params); const queryFn: QueryFunction>> = ({signal}) => - hentSaksDetaljer(params, {signal, ...fetchOptions}); + hentSaksDetaljer(params, {signal, ...requestOptions}); return {queryKey, queryFn, ...queryOptions} as UseQueryOptions< Awaited>, @@ -76,7 +76,7 @@ export function useHentSaksDetaljer>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; } ): DefinedUseQueryResult & {queryKey: QueryKey}; export function useHentSaksDetaljer>, TError = unknown>( @@ -87,14 +87,14 @@ export function useHentSaksDetaljer>, TError, TData>, "initialData" >; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; export function useHentSaksDetaljer>, TError = unknown>( params: HentSaksDetaljerParams, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; @@ -102,7 +102,7 @@ export function useHentSaksDetaljer>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getHentSaksDetaljerQueryOptions(params, options); @@ -119,13 +119,10 @@ export const getHentAlleSakerUrl = () => { }; export const hentAlleSaker = async (options?: RequestInit): Promise => { - const res = await fetch(getHentAlleSakerUrl(), { + return customFetch>(getHentAlleSakerUrl(), { ...options, method: "GET", }); - const data = await res.json(); - - return data as SaksListeResponse[]; }; export const getHentAlleSakerQueryKey = () => { @@ -137,14 +134,14 @@ export const getHentAlleSakerQueryOptions = < TError = unknown, >(options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; }) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getHentAlleSakerQueryKey(); const queryFn: QueryFunction>> = ({signal}) => - hentAlleSaker({signal, ...fetchOptions}); + hentAlleSaker({signal, ...requestOptions}); return {queryKey, queryFn, ...queryOptions} as UseQueryOptions< Awaited>, @@ -159,21 +156,21 @@ export type HentAlleSakerQueryError = unknown; export function useHentAlleSaker>, TError = unknown>(options: { query: Partial>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; }): DefinedUseQueryResult & {queryKey: QueryKey}; export function useHentAlleSaker>, TError = unknown>(options?: { query?: Partial>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; }): UseQueryResult & {queryKey: QueryKey}; export function useHentAlleSaker>, TError = unknown>(options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; }): UseQueryResult & {queryKey: QueryKey}; export function useHentAlleSaker>, TError = unknown>(options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; }): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getHentAlleSakerQueryOptions(options); diff --git a/src/generated/saks-status-controller/saks-status-controller.ts b/src/generated/saks-status-controller/saks-status-controller.ts index 18f665ea..e4bb2124 100644 --- a/src/generated/saks-status-controller/saks-status-controller.ts +++ b/src/generated/saks-status-controller/saks-status-controller.ts @@ -15,19 +15,19 @@ import type { UseQueryResult, } from "@tanstack/react-query"; import type {SaksStatusResponse} from ".././model"; +import {customFetch} from "../../custom-fetch"; + +type SecondParameter any> = Parameters[1]; export const getHentSaksStatuserUrl = (fiksDigisosId: string) => { return `/sosialhjelp/innsyn/api/innsyn-api/api/v1/innsyn/${fiksDigisosId}/saksStatus`; }; export const hentSaksStatuser = async (fiksDigisosId: string, options?: RequestInit): Promise => { - const res = await fetch(getHentSaksStatuserUrl(fiksDigisosId), { + return customFetch>(getHentSaksStatuserUrl(fiksDigisosId), { ...options, method: "GET", }); - const data = await res.json(); - - return data as SaksStatusResponse[]; }; export const getHentSaksStatuserQueryKey = (fiksDigisosId: string) => { @@ -38,15 +38,15 @@ export const getHentSaksStatuserQueryOptions = >, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getHentSaksStatuserQueryKey(fiksDigisosId); const queryFn: QueryFunction>> = ({signal}) => - hentSaksStatuser(fiksDigisosId, {signal, ...fetchOptions}); + hentSaksStatuser(fiksDigisosId, {signal, ...requestOptions}); return {queryKey, queryFn, enabled: !!fiksDigisosId, ...queryOptions} as UseQueryOptions< Awaited>, @@ -63,7 +63,7 @@ export function useHentSaksStatuser>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; } ): DefinedUseQueryResult & {queryKey: QueryKey}; export function useHentSaksStatuser>, TError = unknown>( @@ -74,14 +74,14 @@ export function useHentSaksStatuser>, TError, TData>, "initialData" >; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; export function useHentSaksStatuser>, TError = unknown>( fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; @@ -89,7 +89,7 @@ export function useHentSaksStatuser>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getHentSaksStatuserQueryOptions(fiksDigisosId, options); diff --git a/src/generated/soknad-med-innsyn-controller/soknad-med-innsyn-controller.ts b/src/generated/soknad-med-innsyn-controller/soknad-med-innsyn-controller.ts index ddad8992..fa1db58b 100644 --- a/src/generated/soknad-med-innsyn-controller/soknad-med-innsyn-controller.ts +++ b/src/generated/soknad-med-innsyn-controller/soknad-med-innsyn-controller.ts @@ -14,19 +14,19 @@ import type { UseQueryOptions, UseQueryResult, } from "@tanstack/react-query"; +import {customFetch} from "../../custom-fetch"; + +type SecondParameter any> = Parameters[1]; export const getHarSoknaderMedInnsynUrl = () => { return `/sosialhjelp/innsyn/api/innsyn-api/api/v1/innsyn/harSoknaderMedInnsyn`; }; export const harSoknaderMedInnsyn = async (options?: RequestInit): Promise => { - const res = await fetch(getHarSoknaderMedInnsynUrl(), { + return customFetch>(getHarSoknaderMedInnsynUrl(), { ...options, method: "GET", }); - const data = await res.json(); - - return data as boolean; }; export const getHarSoknaderMedInnsynQueryKey = () => { @@ -38,14 +38,14 @@ export const getHarSoknaderMedInnsynQueryOptions = < TError = unknown, >(options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; }) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getHarSoknaderMedInnsynQueryKey(); const queryFn: QueryFunction>> = ({signal}) => - harSoknaderMedInnsyn({signal, ...fetchOptions}); + harSoknaderMedInnsyn({signal, ...requestOptions}); return {queryKey, queryFn, ...queryOptions} as UseQueryOptions< Awaited>, @@ -63,7 +63,7 @@ export function useHarSoknaderMedInnsyn< >(options: { query: Partial>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; }): DefinedUseQueryResult & {queryKey: QueryKey}; export function useHarSoknaderMedInnsyn< TData = Awaited>, @@ -74,14 +74,14 @@ export function useHarSoknaderMedInnsyn< UndefinedInitialDataOptions>, TError, TData>, "initialData" >; - fetch?: RequestInit; + request?: SecondParameter; }): UseQueryResult & {queryKey: QueryKey}; export function useHarSoknaderMedInnsyn< TData = Awaited>, TError = unknown, >(options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; }): UseQueryResult & {queryKey: QueryKey}; export function useHarSoknaderMedInnsyn< @@ -89,7 +89,7 @@ export function useHarSoknaderMedInnsyn< TError = unknown, >(options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; }): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getHarSoknaderMedInnsynQueryOptions(options); diff --git a/src/generated/soknads-status-controller/soknads-status-controller.ts b/src/generated/soknads-status-controller/soknads-status-controller.ts index 848c081f..084ab194 100644 --- a/src/generated/soknads-status-controller/soknads-status-controller.ts +++ b/src/generated/soknads-status-controller/soknads-status-controller.ts @@ -15,6 +15,9 @@ import type { UseQueryResult, } from "@tanstack/react-query"; import type {SoknadsStatusResponse} from ".././model"; +import {customFetch} from "../../custom-fetch"; + +type SecondParameter any> = Parameters[1]; export const getHentSoknadsStatusUrl = (fiksDigisosId: string) => { return `/sosialhjelp/innsyn/api/innsyn-api/api/v1/innsyn/${fiksDigisosId}/soknadsStatus`; @@ -24,13 +27,10 @@ export const hentSoknadsStatus = async ( fiksDigisosId: string, options?: RequestInit ): Promise => { - const res = await fetch(getHentSoknadsStatusUrl(fiksDigisosId), { + return customFetch>(getHentSoknadsStatusUrl(fiksDigisosId), { ...options, method: "GET", }); - const data = await res.json(); - - return data as SoknadsStatusResponse; }; export const getHentSoknadsStatusQueryKey = (fiksDigisosId: string) => { @@ -44,15 +44,15 @@ export const getHentSoknadsStatusQueryOptions = < fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getHentSoknadsStatusQueryKey(fiksDigisosId); const queryFn: QueryFunction>> = ({signal}) => - hentSoknadsStatus(fiksDigisosId, {signal, ...fetchOptions}); + hentSoknadsStatus(fiksDigisosId, {signal, ...requestOptions}); return {queryKey, queryFn, enabled: !!fiksDigisosId, ...queryOptions} as UseQueryOptions< Awaited>, @@ -72,7 +72,7 @@ export function useHentSoknadsStatus>, TError, TData>, "initialData" >; - fetch?: RequestInit; + request?: SecondParameter; } ): DefinedUseQueryResult & {queryKey: QueryKey}; export function useHentSoknadsStatus>, TError = unknown>( @@ -83,14 +83,14 @@ export function useHentSoknadsStatus>, TError, TData>, "initialData" >; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; export function useHentSoknadsStatus>, TError = unknown>( fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; @@ -98,7 +98,7 @@ export function useHentSoknadsStatus>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getHentSoknadsStatusQueryOptions(fiksDigisosId, options); diff --git a/src/generated/tilgang-controller/tilgang-controller.ts b/src/generated/tilgang-controller/tilgang-controller.ts index 72eaeec3..8d062f08 100644 --- a/src/generated/tilgang-controller/tilgang-controller.ts +++ b/src/generated/tilgang-controller/tilgang-controller.ts @@ -15,6 +15,9 @@ import type { UseQueryResult, } from "@tanstack/react-query"; import type {TilgangResponse} from ".././model"; +import {customFetch} from "../../custom-fetch"; + +type SecondParameter any> = Parameters[1]; export type harTilgangResponse = { data: TilgangResponse; @@ -26,13 +29,10 @@ export const getHarTilgangUrl = () => { }; export const harTilgang = async (options?: RequestInit): Promise => { - const res = await fetch(getHarTilgangUrl(), { + return customFetch>(getHarTilgangUrl(), { ...options, method: "GET", }); - const data = await res.json(); - - return {status: res.status, data}; }; export const getHarTilgangQueryKey = () => { @@ -41,14 +41,14 @@ export const getHarTilgangQueryKey = () => { export const getHarTilgangQueryOptions = >, TError = unknown>(options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; }) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getHarTilgangQueryKey(); const queryFn: QueryFunction>> = ({signal}) => - harTilgang({signal, ...fetchOptions}); + harTilgang({signal, ...requestOptions}); return {queryKey, queryFn, ...queryOptions} as UseQueryOptions< Awaited>, @@ -63,21 +63,21 @@ export type HarTilgangQueryError = unknown; export function useHarTilgang>, TError = unknown>(options: { query: Partial>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; }): DefinedUseQueryResult & {queryKey: QueryKey}; export function useHarTilgang>, TError = unknown>(options?: { query?: Partial>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; }): UseQueryResult & {queryKey: QueryKey}; export function useHarTilgang>, TError = unknown>(options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; }): UseQueryResult & {queryKey: QueryKey}; export function useHarTilgang>, TError = unknown>(options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; }): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getHarTilgangQueryOptions(options); diff --git a/src/generated/utbetalinger-controller/utbetalinger-controller.ts b/src/generated/utbetalinger-controller/utbetalinger-controller.ts index 941e1d1e..201681f9 100644 --- a/src/generated/utbetalinger-controller/utbetalinger-controller.ts +++ b/src/generated/utbetalinger-controller/utbetalinger-controller.ts @@ -15,6 +15,9 @@ import type { UseQueryResult, } from "@tanstack/react-query"; import type {HentUtbetalingerParams, NyeOgTidligereUtbetalingerResponse, UtbetalingerResponse} from ".././model"; +import {customFetch} from "../../custom-fetch"; + +type SecondParameter any> = Parameters[1]; export const getHentUtbetalingerUrl = (params?: HentUtbetalingerParams) => { const normalizedParams = new URLSearchParams(); @@ -34,13 +37,10 @@ export const hentUtbetalinger = async ( params?: HentUtbetalingerParams, options?: RequestInit ): Promise => { - const res = await fetch(getHentUtbetalingerUrl(params), { + return customFetch>(getHentUtbetalingerUrl(params), { ...options, method: "GET", }); - const data = await res.json(); - - return data as UtbetalingerResponse[]; }; export const getHentUtbetalingerQueryKey = (params?: HentUtbetalingerParams) => { @@ -51,15 +51,15 @@ export const getHentUtbetalingerQueryOptions = >, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getHentUtbetalingerQueryKey(params); const queryFn: QueryFunction>> = ({signal}) => - hentUtbetalinger(params, {signal, ...fetchOptions}); + hentUtbetalinger(params, {signal, ...requestOptions}); return {queryKey, queryFn, ...queryOptions} as UseQueryOptions< Awaited>, @@ -76,7 +76,7 @@ export function useHentUtbetalinger>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; } ): DefinedUseQueryResult & {queryKey: QueryKey}; export function useHentUtbetalinger>, TError = unknown>( @@ -87,14 +87,14 @@ export function useHentUtbetalinger>, TError, TData>, "initialData" >; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; export function useHentUtbetalinger>, TError = unknown>( params?: HentUtbetalingerParams, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; @@ -102,7 +102,7 @@ export function useHentUtbetalinger>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getHentUtbetalingerQueryOptions(params, options); @@ -121,13 +121,10 @@ export const getHentTidligereUtbetalingerUrl = () => { export const hentTidligereUtbetalinger = async ( options?: RequestInit ): Promise => { - const res = await fetch(getHentTidligereUtbetalingerUrl(), { + return customFetch>(getHentTidligereUtbetalingerUrl(), { ...options, method: "GET", }); - const data = await res.json(); - - return data as NyeOgTidligereUtbetalingerResponse[]; }; export const getHentTidligereUtbetalingerQueryKey = () => { @@ -139,14 +136,14 @@ export const getHentTidligereUtbetalingerQueryOptions = < TError = unknown, >(options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; }) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getHentTidligereUtbetalingerQueryKey(); const queryFn: QueryFunction>> = ({signal}) => - hentTidligereUtbetalinger({signal, ...fetchOptions}); + hentTidligereUtbetalinger({signal, ...requestOptions}); return {queryKey, queryFn, ...queryOptions} as UseQueryOptions< Awaited>, @@ -167,7 +164,7 @@ export function useHentTidligereUtbetalinger< DefinedInitialDataOptions>, TError, TData>, "initialData" >; - fetch?: RequestInit; + request?: SecondParameter; }): DefinedUseQueryResult & {queryKey: QueryKey}; export function useHentTidligereUtbetalinger< TData = Awaited>, @@ -178,14 +175,14 @@ export function useHentTidligereUtbetalinger< UndefinedInitialDataOptions>, TError, TData>, "initialData" >; - fetch?: RequestInit; + request?: SecondParameter; }): UseQueryResult & {queryKey: QueryKey}; export function useHentTidligereUtbetalinger< TData = Awaited>, TError = unknown, >(options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; }): UseQueryResult & {queryKey: QueryKey}; export function useHentTidligereUtbetalinger< @@ -193,7 +190,7 @@ export function useHentTidligereUtbetalinger< TError = unknown, >(options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; }): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getHentTidligereUtbetalingerQueryOptions(options); @@ -209,13 +206,10 @@ export const getHentNyeUtbetalingerUrl = () => { }; export const hentNyeUtbetalinger = async (options?: RequestInit): Promise => { - const res = await fetch(getHentNyeUtbetalingerUrl(), { + return customFetch>(getHentNyeUtbetalingerUrl(), { ...options, method: "GET", }); - const data = await res.json(); - - return data as NyeOgTidligereUtbetalingerResponse[]; }; export const getHentNyeUtbetalingerQueryKey = () => { @@ -227,14 +221,14 @@ export const getHentNyeUtbetalingerQueryOptions = < TError = unknown, >(options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; }) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getHentNyeUtbetalingerQueryKey(); const queryFn: QueryFunction>> = ({signal}) => - hentNyeUtbetalinger({signal, ...fetchOptions}); + hentNyeUtbetalinger({signal, ...requestOptions}); return {queryKey, queryFn, ...queryOptions} as UseQueryOptions< Awaited>, @@ -252,7 +246,7 @@ export function useHentNyeUtbetalinger< >(options: { query: Partial>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; }): DefinedUseQueryResult & {queryKey: QueryKey}; export function useHentNyeUtbetalinger< TData = Awaited>, @@ -263,14 +257,14 @@ export function useHentNyeUtbetalinger< UndefinedInitialDataOptions>, TError, TData>, "initialData" >; - fetch?: RequestInit; + request?: SecondParameter; }): UseQueryResult & {queryKey: QueryKey}; export function useHentNyeUtbetalinger< TData = Awaited>, TError = unknown, >(options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; }): UseQueryResult & {queryKey: QueryKey}; export function useHentNyeUtbetalinger< @@ -278,7 +272,7 @@ export function useHentNyeUtbetalinger< TError = unknown, >(options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; }): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getHentNyeUtbetalingerQueryOptions(options); diff --git a/src/generated/vedlegg-controller/vedlegg-controller.ts b/src/generated/vedlegg-controller/vedlegg-controller.ts index a4ac79c0..b3e08723 100644 --- a/src/generated/vedlegg-controller/vedlegg-controller.ts +++ b/src/generated/vedlegg-controller/vedlegg-controller.ts @@ -18,19 +18,19 @@ import type { UseQueryResult, } from "@tanstack/react-query"; import type {OppgaveOpplastingResponse, SendVedleggBody, VedleggResponse} from ".././model"; +import {customFetch} from "../../custom-fetch"; + +type SecondParameter any> = Parameters[1]; export const getHentVedleggUrl = (fiksDigisosId: string) => { return `/sosialhjelp/innsyn/api/innsyn-api/api/v1/innsyn/${fiksDigisosId}/vedlegg`; }; export const hentVedlegg = async (fiksDigisosId: string, options?: RequestInit): Promise => { - const res = await fetch(getHentVedleggUrl(fiksDigisosId), { + return customFetch>(getHentVedleggUrl(fiksDigisosId), { ...options, method: "GET", }); - const data = await res.json(); - - return data as VedleggResponse[]; }; export const getHentVedleggQueryKey = (fiksDigisosId: string) => { @@ -41,15 +41,15 @@ export const getHentVedleggQueryOptions = >, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ) => { - const {query: queryOptions, fetch: fetchOptions} = options ?? {}; + const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getHentVedleggQueryKey(fiksDigisosId); const queryFn: QueryFunction>> = ({signal}) => - hentVedlegg(fiksDigisosId, {signal, ...fetchOptions}); + hentVedlegg(fiksDigisosId, {signal, ...requestOptions}); return {queryKey, queryFn, enabled: !!fiksDigisosId, ...queryOptions} as UseQueryOptions< Awaited>, @@ -66,7 +66,7 @@ export function useHentVedlegg>, options: { query: Partial>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; } ): DefinedUseQueryResult & {queryKey: QueryKey}; export function useHentVedlegg>, TError = unknown>( @@ -74,14 +74,14 @@ export function useHentVedlegg>, options?: { query?: Partial>, TError, TData>> & Pick>, TError, TData>, "initialData">; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; export function useHentVedlegg>, TError = unknown>( fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey}; @@ -89,7 +89,7 @@ export function useHentVedlegg>, fiksDigisosId: string, options?: { query?: Partial>, TError, TData>>; - fetch?: RequestInit; + request?: SecondParameter; } ): UseQueryResult & {queryKey: QueryKey} { const queryOptions = getHentVedleggQueryOptions(fiksDigisosId, options); @@ -113,14 +113,11 @@ export const sendVedlegg = async ( const formData = new FormData(); sendVedleggBody.files.forEach((value) => formData.append("files", value)); - const res = await fetch(getSendVedleggUrl(fiksDigisosId), { + return customFetch>(getSendVedleggUrl(fiksDigisosId), { ...options, method: "POST", body: formData, }); - const data = await res.json(); - - return data as OppgaveOpplastingResponse[]; }; export const getSendVedleggMutationOptions = (options?: { @@ -130,14 +127,14 @@ export const getSendVedleggMutationOptions = ; - fetch?: RequestInit; + request?: SecondParameter; }): UseMutationOptions< Awaited>, TError, {fiksDigisosId: string; data: SendVedleggBody}, TContext > => { - const {mutation: mutationOptions, fetch: fetchOptions} = options ?? {}; + const {mutation: mutationOptions, request: requestOptions} = options ?? {}; const mutationFn: MutationFunction< Awaited>, @@ -145,7 +142,7 @@ export const getSendVedleggMutationOptions = = (props) => { const {fiksDigisosId, data} = props ?? {}; - return sendVedlegg(fiksDigisosId, data, fetchOptions); + return sendVedlegg(fiksDigisosId, data, requestOptions); }; return {mutationFn, ...mutationOptions}; @@ -162,7 +159,7 @@ export const useSendVedlegg = (options?: { {fiksDigisosId: string; data: SendVedleggBody}, TContext >; - fetch?: RequestInit; + request?: SecondParameter; }): UseMutationResult< Awaited>, TError, diff --git a/src/pages/[id]/status.tsx b/src/pages/[id]/status.tsx index ead3fb2c..9050bf59 100644 --- a/src/pages/[id]/status.tsx +++ b/src/pages/[id]/status.tsx @@ -64,6 +64,7 @@ const SaksStatusView: NextPage = () => { const searchParams = useSearchParams(); const showUxSignalsWidget = Boolean(searchParams.get("kortSoknad")); + console.log("saksstatuser: ", saksStatuser); useEffect(() => { function createAmplitudeData() { const harVedtaksbrev = saksStatuser && saksStatuser.some((item) => item.vedtaksfilUrlList?.length); diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 39a0e5cb..c8e8d7ff 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -10,6 +10,7 @@ import MainLayout from "../components/MainLayout"; import useUpdateBreadcrumbs from "../hooks/useUpdateBreadcrumbs"; import pageHandler from "../pagehandler/pageHandler"; import styled from "styled-components"; +import {log} from "next/dist/server/typescript/utils"; const StyledAlert = styled(Alert)` margin-bottom: 1.5rem; @@ -21,6 +22,7 @@ const Saksoversikt: NextPage = () => { useUpdateBreadcrumbs(() => []); const {data: saker, isLoading, error} = useHentAlleSaker(); + console.log("saker: ", saker); return ( {isLoading && }