Skip to content

Commit

Permalink
Flytt 'videresendTilInnlogging'-util til fellesmappa
Browse files Browse the repository at this point in the history
  • Loading branch information
Kjetil Svalestuen committed Jul 5, 2023
1 parent e5dae19 commit a886ba8
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 19 deletions.
4 changes: 4 additions & 0 deletions src/felles/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ export const api = {
kandidatsøk: '/kandidatsok-proxy',
forespørselOmDelingAvCv: '/foresporsel-om-deling-av-cv-api',
};

export const videresendTilInnlogging = () => {
window.location.href = `/oauth2/login?redirect=${window.location.pathname}`;
};
6 changes: 1 addition & 5 deletions src/forside/statistikk/useSvarstatistikk.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useState } from 'react';
import { formaterDatoTilApi } from './datoUtils';
import { Nettressurs } from '../../felles/nettressurs';
import { api } from '../../felles/api';
import { api, videresendTilInnlogging } from '../../felles/api';

export type Svarstatistikk = {
antallSvartJa: number;
Expand Down Expand Up @@ -59,8 +59,4 @@ const useSvarstatistikk = (navKontor: string, fraOgMed: Date, tilOgMed: Date) =>
return svarstatistikk;
};

const videresendTilInnlogging = () => {
window.location.href = `/oauth2/login?redirect=${window.location.pathname}`;
};

export default useSvarstatistikk;
5 changes: 1 addition & 4 deletions src/kandidat/api/fetchUtils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { videresendTilInnlogging } from '../../felles/api';
import { lenkeTilTilgangsside } from '../app/paths';
import { feil, Nettressurs, suksess } from './Nettressurs';

Expand Down Expand Up @@ -54,10 +55,6 @@ export async function fetchJson(url: string, includeCredentials: boolean = false
}
}

const videresendTilInnlogging = () => {
window.location.href = `/oauth2/login?redirect=${window.location.pathname}`;
};

const videresendTilTilgangsside = () => {
window.location.href = lenkeTilTilgangsside;
};
Expand Down
6 changes: 1 addition & 5 deletions src/kandidatsok/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { Kandidatliste, Stilling } from '../hooks/useKontekstAvKandidatlisteEllerStilling';
import { LagreKandidaterDto } from '../kandidatliste/LagreKandidaterIMineKandidatlisterModal';
import { MineKandidatlister } from '../kandidatliste/useMineKandidatlister';
import { api } from '../../felles/api';
import { api, videresendTilInnlogging } from '../../felles/api';

export const søk = async (query: SearchQuery): Promise<Respons> => {
const respons = await post(api.kandidatsøk, query);
Expand Down Expand Up @@ -117,7 +117,3 @@ export const get = (url: string) =>
method: 'GET',
credentials: 'include',
});

const videresendTilInnlogging = () => {
window.location.href = `/oauth2/login?redirect=${window.location.pathname}`;
};
6 changes: 1 addition & 5 deletions src/stillingssok/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { api } from '../../felles/api';
import { api, videresendTilInnlogging } from '../../felles/api';
import { Query, Respons } from '../domene/elasticSearchTyper';
import StandardsøkDto from '../filter/standardsøk/Standardsøk';

Expand Down Expand Up @@ -64,7 +64,3 @@ const jsonRequest = (url: string, body?: object, method: string = 'GET') =>
'Content-Type': 'application/json',
},
});

const videresendTilInnlogging = () => {
window.location.href = `/oauth2/login?redirect=${window.location.pathname}`;
};

0 comments on commit a886ba8

Please sign in to comment.