From 06fddcc9c236f4fa82aa026a89fc1f6133500531 Mon Sep 17 00:00:00 2001 From: Jesper Paulsen Date: Mon, 4 Dec 2023 14:47:40 +0100 Subject: [PATCH] [KAIZEN-0] Ikke fnr i path i varselrequests --- src/rest/resources/varselResource.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/rest/resources/varselResource.tsx b/src/rest/resources/varselResource.tsx index 90b8ab008..db26b5141 100644 --- a/src/rest/resources/varselResource.tsx +++ b/src/rest/resources/varselResource.tsx @@ -1,8 +1,10 @@ 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 { VarslerResult } from '../../models/varsel'; +import useFeatureToggle from '../../components/featureToggle/useFeatureToggle'; +import { FeatureToggles } from '../../components/featureToggle/toggleIDs'; function queryKey(fnr: string): [string, string] { return ['varsel', fnr]; @@ -12,10 +14,15 @@ function url(fnr: string): string { return `${apiBaseUri}/v2/varsler/${fnr}`; } +function urlV2(): string { + return `${apiBaseUri}/v2/varsler`; +} 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;