Skip to content

Commit

Permalink
Forenkle imports til fellesmappa
Browse files Browse the repository at this point in the history
  • Loading branch information
Kjetil Svalestuen committed Jul 5, 2023
1 parent a886ba8 commit e1a8b47
Show file tree
Hide file tree
Showing 37 changed files with 51 additions and 44 deletions.
6 changes: 2 additions & 4 deletions src/felles/amplitude.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import amplitudeJs, { AmplitudeClient } from 'amplitude-js';
import { Miljø, getMiljø } from './miljø';

const SEND_EVENTS = true;

export enum AmplitudeEvent {
Sidevisning = 'sidevisning',
Navigere = 'navigere',
Expand All @@ -23,7 +21,7 @@ export const setNavKontorForAmplitude = (navKontor: string) => {
};

export const sendEvent = (område: string, hendelse: string, data?: Object) => {
if (import.meta.env.PROD && SEND_EVENTS) {
if (import.meta.env.PROD) {
client.logEvent(['#rekrutteringsbistand', område, hendelse].join('-'), data);
}
};
Expand All @@ -32,7 +30,7 @@ export const sendGenerellEvent = (
event: AmplitudeEvent | string,
properties: Record<string, any>
): Promise<void> => {
if (import.meta.env.PROD && SEND_EVENTS) {
if (import.meta.env.PROD) {
const eventProperties = {
app: 'rekrutteringsbistand',
...properties,
Expand Down
2 changes: 1 addition & 1 deletion src/forside/Forside.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Loader } from '@navikt/ds-react';
import Hurtiglenker from './hurtiglenker/Hurtiglenker';
import css from './Forside.module.css';
import useNavKontor from '../felles/store/navKontor';
import useNavKontor from 'felles/store/navKontor';
import Statistikk from './statistikk/Statistikk';

const Forside = () => {
Expand Down
4 changes: 2 additions & 2 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 { api, videresendTilInnlogging } from 'felles/api';
import { formaterDatoTilApi } from './datoUtils';
import { Nettressurs } from '../../felles/nettressurs';
import { api, videresendTilInnlogging } from '../../felles/api';
import { Nettressurs } from 'felles/nettressurs';

export type Svarstatistikk = {
antallSvartJa: number;
Expand Down
2 changes: 1 addition & 1 deletion src/forside/statistikk/useUtfallsstatistikk.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useEffect } from 'react';
import { formaterDatoTilApi } from './datoUtils';
import { api } from '../../felles/api';
import { api } from 'felles/api';

type AntallFormidlingerInboundDto = {
antallPresentert: number;
Expand Down
2 changes: 1 addition & 1 deletion src/header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Outlet } from 'react-router-dom';
import Modiadekoratør from './modiadekoratør/Modiadekoratør';
import Navigeringsmeny from './navigeringsmeny/Navigeringsmeny';
import useNavKontor from '../felles/store/navKontor';
import useNavKontor from 'felles/store/navKontor';
import useAmplitude from './useAmplitude';
import Placeholder from './modiadekoratør/Placeholder';

Expand Down
2 changes: 1 addition & 1 deletion src/header/useAmplitude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
sendGenerellEvent,
AmplitudeEvent,
sendEvent,
} from '../felles/amplitude';
} from 'felles/amplitude';
import { generaliserPath } from './utils/path';
import { useLocation } from 'react-router-dom';

Expand Down
2 changes: 1 addition & 1 deletion src/kandidat/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { FormidlingAvUsynligKandidatOutboundDto } from '../felles/legg-til-kandi
import { MineKandidatlister } from '../kandidatside/fraSøkUtenKontekst/lagre-kandidat-modal/useMineKandidatlister';
import { KandidatlisteDto } from '../kandidatlisteoversikt/modaler/Kandidatlisteskjema';
import Cv from '../cv/reducer/cv-typer';
import { api } from '../../felles/api';
import { api } from 'felles/api';

export const ENHETSREGISTER_API = `/${api.stilling}/search-api`;

Expand Down
4 changes: 2 additions & 2 deletions src/kandidat/api/fetchUtils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { videresendTilInnlogging } from '../../felles/api';
import { videresendTilInnlogging } from 'felles/api';
import { lenkeTilTilgangsside } from '../app/paths';
import { feil, Nettressurs, suksess } from './Nettressurs';

export const createCallIdHeader = () => ({
'Nav-CallId': Math.random().toString(16).substr(2),
'Nav-CallId': Math.random().toString(16).substring(2),
});

export class SearchApiError {
Expand Down
2 changes: 1 addition & 1 deletion src/kandidat/api/forespørselOmDelingAvCvApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from '../kandidatliste/knappe-rad/forespørsel-om-deling-av-cv/Forespørsel';
import { fetchJson, postJson } from './fetchUtils';
import { AktørId } from '../kandidatliste/domene/Kandidat';
import { api } from '../../felles/api';
import { api } from 'felles/api';

export type ForespørslerForStillingInboundDto = Partial<Record<AktørId, ForespørselOmDelingAvCv[]>>;

Expand Down
2 changes: 1 addition & 1 deletion src/kandidat/app/KandidatApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Kandidatside from '../kandidatside/Kandidatside';
import ManglerTilgang from './ManglerTilgang';
import NotFound from '../komponenter/errorside/NotFound';
import store from '../state/reduxStore';
import useNavKontor from '../../felles/store/navKontor';
import useNavKontor from 'felles/store/navKontor';
import Varsling from '../varsling/Varsling';
import css from './KandidatApp.module.css';

Expand Down
2 changes: 1 addition & 1 deletion src/kandidat/felles/legg-til-kandidat-modal/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { api } from '../../../felles/api';
import { api } from 'felles/api';
import { Nettressurs, Nettstatus } from '../../api/Nettressurs';
import { SearchApiError, postHeaders } from '../../api/fetchUtils';
import { Synlighetsevaluering } from './kandidaten-finnes-ikke/Synlighetsevaluering';
Expand Down
2 changes: 1 addition & 1 deletion src/kandidat/mock/mock-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Kandidatutfall } from '../kandidatliste/domene/Kandidat';

import { mock } from './mock-data';
import { meg } from './data/kandidat/veileder.mock';
import { api } from '../../felles/api';
import { api } from 'felles/api';
import { ENHETSREGISTER_API } from '../api/api';

fetchMock.config.fallbackToNetwork = true;
Expand Down
2 changes: 1 addition & 1 deletion src/kandidatsok/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import useKontekstAvKandidatlisteEllerStilling from './hooks/useKontekstAvKandid
import useNavigeringsstate from './hooks/useNavigeringsstate';
import { ØktContext, ØktContextProvider } from './Økt';
import Kandidatsøk from './Kandidatsøk';
import useNavKontor from '../felles/store/navKontor';
import useNavKontor from 'felles/store/navKontor';
import '@reach/combobox/styles.css';

const App = () => {
Expand Down
2 changes: 1 addition & 1 deletion 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, videresendTilInnlogging } 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
2 changes: 1 addition & 1 deletion src/kandidatsok/api/query/målQuery.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sendEvent } from '../../../felles/amplitude';
import { sendEvent } from 'felles/amplitude';
import { Portefølje } from '../../filter/porteføljetabs/PorteføljeTabs';
import { Søkekriterier } from '../../hooks/useSøkekriterier';

Expand Down
2 changes: 1 addition & 1 deletion src/kandidatsok/hooks/useBrukerensIdent.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useEffect } from 'react';
import { get } from '../api/api';
import { api } from '../../felles/api';
import { api } from 'felles/api';

export type InnloggetBruker = {
navIdent: string | null;
Expand Down
2 changes: 1 addition & 1 deletion src/kandidatsok/kandidater/sortering/Sortering.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { ToggleGroup, Tooltip } from '@navikt/ds-react';
import { CheckmarkIcon, ClockIcon } from '@navikt/aksel-icons';
import useSøkekriterier from '../../hooks/useSøkekriterier';
import { FilterParam } from '../../hooks/useRespons';
import { sendEvent } from 'felles/amplitude';
import css from './Sortering.module.css';
import { sendEvent } from '../../../felles/amplitude';

export enum Sortering {
SisteFørst = 'nyeste',
Expand Down
4 changes: 2 additions & 2 deletions src/stilling/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import Stilling, {
Rekrutteringsbistandstilling,
Stillingsinfo,
} from '../domene/Stilling';
import { Miljø, getMiljø } from '../../felles/miljø';
import { api } from '../../felles/api';
import { Miljø, getMiljø } from 'felles/miljø';
import { api } from 'felles/api';

export type Side<T> = {
content: T[];
Expand Down
2 changes: 1 addition & 1 deletion src/stilling/mock/mock-api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fetchMock, { MockRequest, MockResponse, MockResponseFunction } from 'fetch-mock';

import { Rekrutteringsbistandstilling } from '../domene/Stilling';
import { api } from '../../felles/api';
import { api } from 'felles/api';
import fnrsok from './data/fnrsok';
import kandidatliste from './data/kandidatliste';

Expand Down
2 changes: 1 addition & 1 deletion src/stilling/reportee/reporteeReducer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { put, select, takeLatest } from 'redux-saga/effects';
import { fetchGet, ApiError } from '../api/apiUtils';
import { ReporteeAction, ReporteeActionType } from './ReporteeAction';
import { api } from '../../felles/api';
import { api } from 'felles/api';

export type Reportee = {
displayName: string;
Expand Down
4 changes: 2 additions & 2 deletions src/stilling/stilling/adReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { MineStillingerActionType } from '../mine-stillinger/MineStillingerActio
import { VarslingAction, VarslingActionType } from '../common/varsling/varslingReducer';
import { State } from '../redux/store';
import { formatISOString } from '../utils/datoUtils';
import { sendEvent } from '../../felles/amplitude';
import { sendEvent } from 'felles/amplitude';
import Stilling, {
AdminStatus,
Kilde,
Expand All @@ -42,7 +42,7 @@ import Stilling, {
Status,
System,
} from '../domene/Stilling';
import { api } from '../../felles/api';
import { api } from 'felles/api';

export const FETCH_AD = 'FETCH_AD';
export const FETCH_AD_BEGIN = 'FETCH_AD_BEGIN';
Expand Down
2 changes: 1 addition & 1 deletion src/stilling/stilling/adUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Miljø, getMiljø } from '../../felles/miljø';
import { Miljø, getMiljø } from 'felles/miljø';

const visStillingUrl =
getMiljø() === Miljø.DevGcp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { put, takeLatest } from 'redux-saga/effects';
import { fetchGet } from '../../../api/apiUtils';
import { ADD_LOCATION_AREA } from '../../adDataReducer';
import { api } from '../../../../felles/api';
import { api } from 'felles/api';

/** *********************************************************
* ACTIONS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
SAVE_AD_SUCCESS,
FETCH_AD_SUCCESS,
} from '../../adReducer';
import { api } from '../../../../felles/api';
import { api } from 'felles/api';

export const FETCH_LOCATIONS = 'FETCH_LOCATIONS';
export const FETCH_LOCATIONS_BEGIN = 'FETCH_LOCATIONS_BEGIN';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { put, takeLatest, throttle } from 'redux-saga/effects';
import { ApiError, fetchGet } from '../../../../api/apiUtils';
import { SET_STYRK } from '../../../adDataReducer';
import { api } from '../../../../../felles/api';
import { api } from 'felles/api';

export const SET_STYRK_TYPEAHEAD_VALUE = 'SET_STYRK_TYPEAHEAD_VALUE';
export const FETCH_STYRK = 'FETCH_STYRK';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Kandidatliste } from '../legg-til-kandidat-modal/kandidatlistetyper';
import { Nettressurs, Nettstatus } from '../../api/Nettressurs';
import { State } from '../../redux/store';
import { stillingenHarKandidatliste } from '../adUtils';
import { sendGenerellEvent } from '../../../felles/amplitude';
import { sendGenerellEvent } from 'felles/amplitude';
import LeggTilKandidatModal from '../legg-til-kandidat-modal/LeggTilKandidatModal';
import css from './Kandidathandlinger.module.css';
import Stilling from '../../domene/Stilling';
Expand Down
2 changes: 1 addition & 1 deletion src/stilling/stilling/kontekst-av-kandidat/useKandidat.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState, useEffect } from 'react';
import { api } from '../../../felles/api';
import { api } from 'felles/api';

export type EsRespons = {
hits: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { postKandidaterTilKandidatliste } from './kandidatApi';
import { VarslingAction, VarslingActionType } from '../../common/varsling/varslingReducer';
import LeggTilEllerAvbryt from './LeggTilEllerAvbryt';
import css from './LeggTilKandidatModal.module.css';
import { sendEvent } from '../../../felles/amplitude';
import { sendEvent } from 'felles/amplitude';

const MAKS_NOTATLENGDE = 2000;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import BekreftMedNotat from './BekreftMedNotat';
import KandidatenFinnesIkke from './kandidaten-finnes-ikke/KandidatenFinnesIkke';
import LeggTilEllerAvbryt from './LeggTilEllerAvbryt';
import css from './LeggTilKandidatModal.module.css';
import { sendEvent } from '../../../felles/amplitude';
import { sendEvent } from 'felles/amplitude';

type Props = {
kandidatliste: Kandidatliste;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { api } from '../../../felles/api';
import { api } from 'felles/api';
import { ApiError } from '../../api/apiUtils';
import { Nettressurs, Nettstatus } from '../../api/Nettressurs';
import { Kandidat, Kandidatliste, Synlighetsevaluering } from './kandidatlistetyper';
Expand Down
2 changes: 1 addition & 1 deletion src/stillingssok/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { api, videresendTilInnlogging } 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
2 changes: 1 addition & 1 deletion src/stillingssok/filter/inkludering/Inkludering.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { Checkbox, CheckboxGroup } from '@navikt/ds-react';

import { hentSøkekriterier, oppdaterUrlMedParam, QueryParam } from '../../utils/urlUtils';
import { hierarkiAvTagsForFilter, visningsnavnForFilter } from './tags';
import { sendEvent } from 'felles/amplitude';
import Filtergruppe from '../Filtergruppe';
import useNavigering from '../../useNavigering';
import css from '../Filter.module.css';
import { sendEvent } from '../../../felles/amplitude';

const Inkludering: FunctionComponent = () => {
const { searchParams, navigate } = useNavigering();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import useKandidat from './useKandidat';
import Kandidatbanner from '../../felles/banner/kandidatbanner/Kandidatbanner';
import Kandidatbanner from 'felles/banner/kandidatbanner/Kandidatbanner';

type Props = {
fnr: string;
Expand Down
4 changes: 2 additions & 2 deletions src/stillingssok/kontekst-av-kandidat/useKandidat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import {
Yrkejobbønske,
byggKandidatQuery,
} from './kandidatQuery';
import { sendEvent } from '../../felles/amplitude';
import { sendEvent } from 'felles/amplitude';
import fylkerOgKommuner from '../filter/geografi/fylkerOgKommuner.json';
import { api } from '../../felles/api';
import { api } from 'felles/api';

const useKandidat = (fnr: string) => {
const { searchParams, navigate } = useNavigering();
Expand Down
2 changes: 1 addition & 1 deletion src/stillingssok/useSøkMedQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { QueryParam, hentSøkekriterier, oppdaterUrlMedParam } from './utils/url
import { Respons } from './domene/elasticSearchTyper';
import useNavigering from './useNavigering';
import useStandardsøk from './standardsøk/StandardsøkContext';
import { sendEvent } from '../felles/amplitude';
import { sendEvent } from 'felles/amplitude';

export const DEFAULT_VALGTE_KRITERIER = '?publisert=intern&statuser=publisert';

Expand Down
5 changes: 4 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
"types": ["jest", "vite/client", "vite-plugin-svgr/client"],

"allowSyntheticDefaultImports": true,
"resolveJsonModule": true
"resolveJsonModule": true,
"paths": {
"felles/*": ["./src/felles/*"]
}
},
"include": ["src", "mock"]
}
6 changes: 6 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineConfig, splitVendorChunkPlugin, loadEnv } from 'vite';
import reactPlugin from '@vitejs/plugin-react';
import svgrPlugin from 'vite-plugin-svgr';
import checkerPlugin from 'vite-plugin-checker';
import path from 'path';

export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
Expand Down Expand Up @@ -43,5 +44,10 @@ export default defineConfig(({ mode }) => {
},
},
},
resolve: {
alias: {
felles: path.resolve(__dirname, './src/felles'),
},
},
};
});

0 comments on commit e1a8b47

Please sign in to comment.