Skip to content

Commit

Permalink
Fjern siste rest av fnr i url
Browse files Browse the repository at this point in the history
  • Loading branch information
tu55eladd committed May 7, 2024
1 parent 7a2214c commit 24068f4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 29 deletions.
7 changes: 3 additions & 4 deletions src/api/personAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import { HarLoggetInnRespons, RegoppslagDto } from '../datatypes/types';
import { PERSON_BASE_URL } from '../environment';
import { fetchToJson, fetchToJsonPlain, postAsJson } from './utils';

export const hentPerson = (fnr: string) => fetchToJsonPlain(`${PERSON_BASE_URL}/v2/person?fnr=${fnr}`);
export const hentPerson = (fnr: string) => {
return postAsJson(`${PERSON_BASE_URL}/v3/hent-person`, { fnr, behandlingsnummer: 'B579' });
};

export const hentAdresse = (fnr: string): Promise<RegoppslagDto> =>
postAsJson(`${PERSON_BASE_URL}/v3/person/hent-postadresse`, { fnr, behandlingsnummer: 'B579' });

export const hentHarNivaa4 = (fnr: string): Promise<HarLoggetInnRespons> =>
fetchToJson(`${PERSON_BASE_URL}/person/${fnr}/harNivaa4`);
21 changes: 0 additions & 21 deletions src/api/utils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import { Status } from '../createGenericSlice';
import { LocalStorageElement, hentFraSessionStorage } from '../mocks/demo/localStorage';
import {
AKTIVITET_BASE_URL,
OPPFOLGING_BASE_URL,
DIALOG_BASE_URL,
VEILEDER_BASE_URL,
VEILARBLEST_BASE_URL,
} from '../environment';

/* eslint-env browser */

Expand Down Expand Up @@ -75,26 +67,13 @@ export function fetchToJsonPlain(url: string, config = { headers: defaultHeaders
}

export function fetchToJson(url: string, config: RequestInit = { headers: defaultHeaders, method: 'get' }) {
const fnr = hentFraSessionStorage(LocalStorageElement.FNR);

const configMedCredentials = {
...DEFAULT_CONFIG,
...config,
};

let fetchUrl = url;

if (
fnr &&
!url.includes(AKTIVITET_BASE_URL) &&
!url.includes(DIALOG_BASE_URL) &&
!url.includes(VEILEDER_BASE_URL) &&
!url.includes(VEILARBLEST_BASE_URL) &&
!url.includes(OPPFOLGING_BASE_URL)
) {
fetchUrl = `${url}${url.indexOf('?') >= 0 ? '&' : '?'}fnr=${fnr}`;
}

return fetch(fetchUrl, configMedCredentials).then(sjekkStatuskode).then(toJson);
}

Expand Down
5 changes: 2 additions & 3 deletions src/mocks/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,8 @@ export const handlers = [
rest.put('/veilarblest/api/informasjon/les', jsonResponse(lest)),

// veilarbperson
rest.get('/veilarbperson/api/v2/person', jsonResponse(getPerson)),
rest.get('/veilarbperson/api/v2/person/postadresse', jsonResponse(getPostadresse)),
rest.get('/veilarbperson/api/person/:fnr/harNivaa4', failOrGetResponse(nivaa4Feilet, getNivaa4)),
rest.post('/veilarbperson/api/v3/hent-person', jsonResponse(getPerson)),
rest.post('/veilarbperson/api/v3/person/hent-postadresse', jsonResponse(getPostadresse)),

// veilarbveileder
rest.get('/veilarbveileder/api/veileder/me', jsonResponse(veilederMe)),
Expand Down
1 change: 0 additions & 1 deletion src/moduler/journalforing/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const Sidebar: FunctionComponent = () => {
const journalføringsStatus = useSelector(selectJournalføringstatus);
const henterForhaandsvisning = [Status.PENDING, Status.RELOADING].includes(forhaandsvisningStatus);
const journalfører = [Status.PENDING, Status.RELOADING].includes(journalføringsStatus);
console.log({ journalføringsStatus });
const { hovedsideRoute } = useRoutes();
const navigate = useNavigate();
const { aktivEnhet: journalførendeEnhet } = useFnrOgEnhetContext();
Expand Down

0 comments on commit 24068f4

Please sign in to comment.