diff --git a/src/rest/resources/foreldrepengerResource.tsx b/src/rest/resources/foreldrepengerResource.tsx index 6ab1b335f..f1a89baae 100644 --- a/src/rest/resources/foreldrepengerResource.tsx +++ b/src/rest/resources/foreldrepengerResource.tsx @@ -2,7 +2,9 @@ import { apiBaseUri } from '../../api/config'; import { useFodselsnummer } from '../../utils/customHooks'; import { ForeldrepengerResponse } from '../../models/ytelse/foreldrepenger'; import { useQuery, UseQueryResult } from '@tanstack/react-query'; -import { FetchError, get } from '../../api/api'; +import { FetchError, get, post } from '../../api/api'; +import useFeatureToggle from '../../components/featureToggle/useFeatureToggle'; +import { FeatureToggles } from '../../components/featureToggle/toggleIDs'; function queryKey(fnr: string): [string, string] { return ['foreldrepenger', fnr]; @@ -11,10 +13,15 @@ function url(fnr: string): string { return `${apiBaseUri}/ytelse/foreldrepenger/${fnr}`; } +function urlV2(): string { + return `${apiBaseUri}/ytelse/foreldrepenger`; +} const resource = { useFetch(): UseQueryResult { const fnr = useFodselsnummer(); - return useQuery(queryKey(fnr), () => get(url(fnr))); + const { isOn } = useFeatureToggle(FeatureToggles.IkkeFnrIPath); + + return useQuery(queryKey(fnr), () => (isOn ? post(urlV2(), fnr) : get(url(fnr)))); } }; export default resource; diff --git a/src/rest/resources/pleiepengerResource.tsx b/src/rest/resources/pleiepengerResource.tsx index c739ed548..32ebc75ff 100644 --- a/src/rest/resources/pleiepengerResource.tsx +++ b/src/rest/resources/pleiepengerResource.tsx @@ -2,7 +2,9 @@ import { apiBaseUri } from '../../api/config'; import { useFodselsnummer } from '../../utils/customHooks'; import { PleiepengerResponse } from '../../models/ytelse/pleiepenger'; import { useQuery, UseQueryResult } from '@tanstack/react-query'; -import { FetchError, get } from '../../api/api'; +import { FetchError, get, post } from '../../api/api'; +import useFeatureToggle from '../../components/featureToggle/useFeatureToggle'; +import { FeatureToggles } from '../../components/featureToggle/toggleIDs'; function queryKey(fnr: string): [string, string] { return ['pleiepenger', fnr]; @@ -12,10 +14,17 @@ function url(fnr: string): string { return `${apiBaseUri}/ytelse/pleiepenger/${fnr}`; } +function urlV2(): string { + return `${apiBaseUri}/ytelse/pleiepenger`; +} + const resource = { useFetch(): UseQueryResult { const fnr = useFodselsnummer(); - return useQuery(queryKey(fnr), () => get(url(fnr))); + + const { isOn } = useFeatureToggle(FeatureToggles.IkkeFnrIPath); + + return useQuery(queryKey(fnr), () => (isOn ? post(urlV2(), fnr) : get(url(fnr)))); } }; export default resource; diff --git a/src/rest/resources/sykepengerResource.tsx b/src/rest/resources/sykepengerResource.tsx index c73eb6e6a..52a1842b9 100644 --- a/src/rest/resources/sykepengerResource.tsx +++ b/src/rest/resources/sykepengerResource.tsx @@ -2,7 +2,9 @@ import { SykepengerResponse } from '../../models/ytelse/sykepenger'; import { apiBaseUri } from '../../api/config'; import { useFodselsnummer } from '../../utils/customHooks'; import { useQuery, UseQueryResult } from '@tanstack/react-query'; -import { FetchError, get } from '../../api/api'; +import { FetchError, get, post } from '../../api/api'; +import useFeatureToggle from '../../components/featureToggle/useFeatureToggle'; +import { FeatureToggles } from '../../components/featureToggle/toggleIDs'; function queryKey(fnr: string): [string, string] { return ['sykepenger', fnr]; @@ -11,10 +13,16 @@ function url(fnr: string): string { return `${apiBaseUri}/ytelse/sykepenger/${fnr}`; } +function urlV2(): string { + return `${apiBaseUri}/ytelse/sykepenger`; +} const resource = { useFetch(): UseQueryResult { const fnr = useFodselsnummer(); - return useQuery(queryKey(fnr), () => get(url(fnr))); + + const { isOn } = useFeatureToggle(FeatureToggles.IkkeFnrIPath); + + return useQuery(queryKey(fnr), () => (isOn ? post(urlV2(), fnr) : get(url(fnr)))); } }; export default resource; diff --git a/src/rest/resources/utbetalingerResource.tsx b/src/rest/resources/utbetalingerResource.tsx index 15c8befae..345cabe67 100644 --- a/src/rest/resources/utbetalingerResource.tsx +++ b/src/rest/resources/utbetalingerResource.tsx @@ -12,7 +12,9 @@ import { import dayjs from 'dayjs'; import { UtbetalingerResponse } from '../../models/utbetalinger'; import { useQuery, UseQueryResult } from '@tanstack/react-query'; -import { FetchError, get } from '../../api/api'; +import { FetchError, get, post } from '../../api/api'; +import useFeatureToggle from '../../components/featureToggle/useFeatureToggle'; +import { FeatureToggles } from '../../components/featureToggle/toggleIDs'; interface Periode { fra: T; @@ -25,6 +27,10 @@ function url(fnr: string, periode: Periode): string { return `${apiBaseUri}/utbetaling/${fnr}?startDato=${periode.fra}&sluttDato=${periode.til}`; } +function urlV2(periode: Periode): string { + return `${apiBaseUri}/utbetaling?startDato=${periode.fra}&sluttDato=${periode.til}`; +} + const defaults: DefaultConfig = { ifPending: , ifError: Kunne ikke laste inn informasjon om brukers oppfølging @@ -48,7 +54,10 @@ function useReduxData(limit30Dager: boolean): [string, Periode] { const resource = { useFetch(limit30Dager: boolean = false): UseQueryResult { const [fnr, periode] = useReduxData(limit30Dager); - return useQuery(queryKey(fnr, limit30Dager), () => get(url(fnr, periode))); + + const { isOn } = useFeatureToggle(FeatureToggles.IkkeFnrIPath); + + return useQuery(queryKey(fnr, limit30Dager), () => (isOn ? post(urlV2(periode), fnr) : get(url(fnr, periode)))); }, useOversiktRenderer(renderer: RendererOrConfig) { const response = this.useFetch(true);