Skip to content

Commit

Permalink
[KAIZEN-0] Fjerne fnr fra ytelserequests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesperpaulsen committed Dec 4, 2023
1 parent 7b9cff8 commit b76d3d0
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
11 changes: 9 additions & 2 deletions src/rest/resources/foreldrepengerResource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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<ForeldrepengerResponse, FetchError> {
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;
13 changes: 11 additions & 2 deletions src/rest/resources/pleiepengerResource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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<PleiepengerResponse, FetchError> {
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;
12 changes: 10 additions & 2 deletions src/rest/resources/sykepengerResource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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<SykepengerResponse, FetchError> {
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;
13 changes: 11 additions & 2 deletions src/rest/resources/utbetalingerResource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
fra: T;
Expand All @@ -25,6 +27,10 @@ function url(fnr: string, periode: Periode<string>): string {
return `${apiBaseUri}/utbetaling/${fnr}?startDato=${periode.fra}&sluttDato=${periode.til}`;
}

function urlV2(periode: Periode<string>): string {
return `${apiBaseUri}/utbetaling?startDato=${periode.fra}&sluttDato=${periode.til}`;
}

const defaults: DefaultConfig = {
ifPending: <CenteredLazySpinner />,
ifError: <AlertStripe type="advarsel">Kunne ikke laste inn informasjon om brukers oppfølging</AlertStripe>
Expand All @@ -48,7 +54,10 @@ function useReduxData(limit30Dager: boolean): [string, Periode<string>] {
const resource = {
useFetch(limit30Dager: boolean = false): UseQueryResult<UtbetalingerResponse, FetchError> {
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<UtbetalingerResponse>) {
const response = this.useFetch(true);
Expand Down

0 comments on commit b76d3d0

Please sign in to comment.