Skip to content

Commit

Permalink
Merge branch 'master' into reintroduser-fiks
Browse files Browse the repository at this point in the history
  • Loading branch information
Oddsor committed Oct 28, 2024
2 parents 08989db + 603cce1 commit 9d804ee
Show file tree
Hide file tree
Showing 33 changed files with 467 additions and 385 deletions.
122 changes: 4 additions & 118 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,124 +1,10 @@
import AvtaleFetcher from '@/AvtaleSide/AvtaleFetcher';
import AlleredeOpprettetAvtaleProvider from '@/komponenter/alleredeOpprettetTiltak/api/AlleredeOpprettetAvtaleProvider';
import Oversikt from '@/Oversikt';
import * as React from 'react';
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import AdvarselBannerTestversjon from './AdvarselBannerTestversjon/AdvarselBannerTestversjon';
import AvtaleProvider from './AvtaleProvider';
import AvtaleSide from './AvtaleSide/AvtaleSide';
import BeslutterSide from './BeslutterSide/BeslutterSide';
import { FeatureToggleProvider } from './FeatureToggleProvider';
import { FeilVarselProvider } from './FeilVarselProvider';
import Informasjonsside from './Informasjonsside/Informasjonsside';
import InnloggingBoundary from './InnloggingBoundary/InnloggingBoundary';
import { VarselOmNedetid } from './InnloggingBoundary/VarselOmNedetid';
import ErrorBoundary from './komponenter/ErrorBoundary';
import Slettemerk from './komponenter/Slettemerk';
import { NotifikasjonWidgetProvider } from './NotifikasjonWidgetProvider';
import OpprettAvtaleArbeidsgiver from './OpprettAvtale/OpprettAvtaleArbeidsgiver/OpprettAvtaleArbeidsgiver';
import OpprettAvtaleVeileder from './OpprettAvtale/OpprettAvtaleVeileder/OpprettAvtaleVeileder';
import { RouterProvider } from 'react-router-dom';

import {
basename,
pathTilAvtale,
pathTilInformasjonssideInnlogget,
pathTilInformasjonssideUinnlogget,
pathTilOpprettAvtale,
pathTilOpprettAvtaleArbeidsgiver,
pathTilStegIAvtale,
} from './paths';
import RedirectEtterLogin from './RedirectEtterLogin';
import router from './Router';

class App extends React.Component {
render() {
return (
<ErrorBoundary>
<BrowserRouter basename={basename}>
<AdvarselBannerTestversjon />
<VarselOmNedetid />
<Routes>
<Route path={pathTilInformasjonssideUinnlogget} element={<Informasjonsside />} />
<Route
path="*"
element={
<FeilVarselProvider>
<InnloggingBoundary>
<FeatureToggleProvider>
<RedirectEtterLogin>
<AlleredeOpprettetAvtaleProvider>
<NotifikasjonWidgetProvider>
<Routes>
<Route path="/" element={<Oversikt />} />
<Route
path={pathTilInformasjonssideInnlogget}
element={<Informasjonsside />}
/>
<Route
path={pathTilOpprettAvtale}
element={<OpprettAvtaleVeileder />}
/>
<Route
path={pathTilOpprettAvtaleArbeidsgiver}
element={<OpprettAvtaleArbeidsgiver />}
/>
</Routes>
<Routes>
<Route
path={pathTilAvtale(':avtaleId/*')}
element={
<AvtaleProvider>
<AvtaleFetcher>
<Routes>
<Route
path="/"
element={<AvtaleSide />}
/>
<Route
path="/:stegPath"
element={<AvtaleSide />}
/>

<Route
path={`/beslutte/`}
element={<BeslutterSide />}
/>

<Route
path={`/beslutte/:tilskuddsperiodeId`}
element={<BeslutterSide />}
/>

<Route
path={`/slett`}
element={<Slettemerk />}
/>

<Route
path={pathTilStegIAvtale(
':avtaleId',
':stegPath',
)}
element={<AvtaleSide />}
/>
</Routes>
</AvtaleFetcher>
</AvtaleProvider>
}
/>
</Routes>
</NotifikasjonWidgetProvider>
</AlleredeOpprettetAvtaleProvider>
</RedirectEtterLogin>
</FeatureToggleProvider>
</InnloggingBoundary>
</FeilVarselProvider>
}
/>
</Routes>
</BrowserRouter>
</ErrorBoundary>
);
}
function App() {
return <RouterProvider router={router} />;
}

export default App;
47 changes: 24 additions & 23 deletions src/AvtaleOversikt/AvtaleOversikt.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
import { FunctionComponent, useContext, useEffect, useState } from 'react';
import { useSearchParams } from 'react-router-dom';
import { Pagination, Select } from '@navikt/ds-react';
import omit from 'lodash.omit';
import isEqual from 'lodash.isequal';

import './AvtaleOversikt.less';
import ArbeidsgiverFiltrering from '@/AvtaleOversikt/Filtrering/ArbeidsgiverFiltrering';
import AvtaleOversiktArbeidsgiverInformasjon from '@/AvtaleOversikt/AvtaleOversiktArbeidsgiverInformasjon';
import Avtaler from '@/AvtaleOversikt/Avtaler';
import ArbeidsgiverFiltrering from '@/AvtaleOversikt/Filtrering/ArbeidsgiverFiltrering';
import VeilederFiltrering from '@/AvtaleOversikt/Filtrering/VeilederFiltrering';
import { useFilter } from '@/AvtaleOversikt/Filtrering/useFilter';
import LesMerOmLøsningen from '@/AvtaleOversikt/LesMerOmLøsningen/LesMerOmLøsningen';
import useAvtaleOversiktLayout from '@/AvtaleOversikt/useAvtaleOversiktLayout';
import { InnloggetBrukerContext } from '@/InnloggingBoundary/InnloggingBoundary';
import PlussIkon from '@/assets/ikoner/pluss-tegn.svg?react';
import BEMHelper from '@/utils/bem';
import Banner from '@/komponenter/Banner/Banner';
import BannerNAVAnsatt from '@/komponenter/Banner/BannerNAVAnsatt';
import Dokumenttittel from '@/komponenter/Dokumenttittel';
import VerticalSpacer from '@/komponenter/layout/VerticalSpacer';
import LenkeKnapp from '@/komponenter/lenkeknapp/LenkeKnapp';
import { pathTilOpprettAvtale, pathTilOpprettAvtaleArbeidsgiver } from '@/paths';
import LesMerOmLøsningen from '@/AvtaleOversikt/LesMerOmLøsningen/LesMerOmLøsningen';
import PlussIkon from '@/assets/ikoner/pluss-tegn.svg?react';
import VeilederFiltrering from '@/AvtaleOversikt/Filtrering/VeilederFiltrering';
import VerticalSpacer from '@/komponenter/layout/VerticalSpacer';
import useAvtaleOversiktLayout from '@/AvtaleOversikt/useAvtaleOversiktLayout';
import { Avtale, PageableAvtale } from '@/types/avtale';
import { FiltreringContext } from './Filtrering/FiltreringProvider';
import { InnloggetBrukerContext } from '@/InnloggingBoundary/InnloggingBoundary';
import { Path } from '@/Router';
import { Status } from '@/types/nettressurs';
import { Varsel } from '@/types/varsel';
import { fjernTommeFelterFraObjekt, litenForbokstav } from '@/utils/stringUtils';
import { useFilter } from '@/AvtaleOversikt/Filtrering/useFilter';
import {
hentAvtalerForInnloggetBrukerMedPost,
hentAvtalerForInnloggetBrukerMedSokId,
hentUlesteVarsler,
} from '@/services/rest-service';
import { Avtale, PageableAvtale } from '@/types/avtale';
import { Status } from '@/types/nettressurs';
import { Varsel } from '@/types/varsel';
import BEMHelper from '@/utils/bem';
import { fjernTommeFelterFraObjekt, litenForbokstav } from '@/utils/stringUtils';
import { Pagination, Select } from '@navikt/ds-react';
import isEqual from 'lodash.isequal';
import omit from 'lodash.omit';
import { FunctionComponent, useContext, useEffect, useState } from 'react';
import { useSearchParams } from 'react-router-dom';
import './AvtaleOversikt.less';
import { FiltreringContext } from './Filtrering/FiltreringProvider';

const cls = BEMHelper('avtaleoversikt');
const clsPagination = BEMHelper('avtaleoversikt-pagination');
Expand Down Expand Up @@ -215,7 +216,7 @@ const AvtaleOversikt: FunctionComponent = () => {
{innloggetBruker.rolle === 'VEILEDER' && (
<aside style={layout.stylingAvFilter}>
<div style={{ margin: '0.2rem 0 1rem 0' }}>
<LenkeKnapp path={pathTilOpprettAvtale} icon={<PlussIkon />}>
<LenkeKnapp path={Path.OPPRETT_AVTALE} icon={<PlussIkon />}>
Opprett ny avtale
</LenkeKnapp>
</div>
Expand All @@ -228,7 +229,7 @@ const AvtaleOversikt: FunctionComponent = () => {
<aside style={layout.stylingAvFilter}>
{harTilgangerSomArbeidsgiver && (
<div style={{ margin: '0.2rem 0 1rem 0' }}>
<LenkeKnapp path={pathTilOpprettAvtaleArbeidsgiver} icon={<PlussIkon />}>
<LenkeKnapp path={Path.OPPRETT_AVTALE_ARBEIDSGIVER} icon={<PlussIkon />}>
Opprett ny avtale
</LenkeKnapp>
</div>
Expand Down
23 changes: 12 additions & 11 deletions src/AvtaleOversikt/AvtaleTabell.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import React, { FunctionComponent, useState } from 'react';
import { useNavigate, generatePath } from 'react-router-dom';
import MediaQuery from 'react-responsive';

import './AvtaleTabell.less';
import AvtaleTabellRadHeader from '@/AvtaleOversikt/AvtaleTabellRadHeader';
import BEMHelper from '@/utils/bem';
import StatusIkon from '@/komponenter/StatusIkon/StatusIkon';
import { avtaleStatusTekst, tiltakstypeTekstKort } from '@/messages';
import { pathTilAvtaleNy } from '@/paths';
import TaushetserklæringModal from './Taushetserklæring/Taushetserklæring';
import { AvtaleMinimalListeVisning } from '@/types/avtale';
import { InnloggetBruker } from '@/types/innlogget-bruker';
import { Varsel } from '@/types/varsel';
import BEMHelper from '@/utils/bem';
import { BodyShort, Table } from '@navikt/ds-react';
import React, { FunctionComponent, useState } from 'react';
import MediaQuery from 'react-responsive';
import { useNavigate } from 'react-router-dom';
import TaushetserklæringModal from './Taushetserklæring/Taushetserklæring';
import './AvtaleTabell.less';
import { ChevronRightIcon } from '@navikt/aksel-icons';
import { InnloggetBruker } from '@/types/innlogget-bruker';
import { Path } from '@/Router';
import { Varsel } from '@/types/varsel';
import { avtaleStatusTekst, tiltakstypeTekstKort } from '@/messages';
import { kunStorForbokstav } from '@/utils/stringUtils';

const cls = BEMHelper('avtaletabell');
Expand Down Expand Up @@ -80,7 +81,7 @@ const AvtaleTabell: FunctionComponent<{
e.preventDefault();
} else {
navigate({
pathname: pathTilAvtaleNy(avtale.id, innloggetBruker.rolle),
pathname: generatePath(Path.AVTALE, { avtaleId: avtale.id }),
search: window.location.search,
});
}
Expand Down
21 changes: 11 additions & 10 deletions src/AvtaleOversikt/AvtalekortMobil.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { Fragment, FunctionComponent, useState } from 'react';
import { useNavigate, generatePath } from 'react-router-dom';
import { LinkPanel, Heading, Ingress, BodyShort } from '@navikt/ds-react';
import moment from 'moment';

import './AvtalekortMobil.less';
import BEMHelper from '@/utils/bem';
import StatusIkon from '@/komponenter/StatusIkon/StatusIkon';
import TaushetserklæringModal from '@/AvtaleOversikt/Taushetserklæring/Taushetserklæring';
import VerticalSpacer from '@/komponenter/layout/VerticalSpacer';
import StatusIkon from '@/komponenter/StatusIkon/StatusIkon';
import { avtaleStatusTekst } from '@/messages';
import { pathTilAvtaleNy } from '@/paths';
import { AvtaleMinimalListeVisning } from '@/types/avtale';
import { InnloggetBruker } from '@/types/innlogget-bruker';
import { Path } from '@/Router';
import { Varsel } from '@/types/varsel';
import BEMHelper from '@/utils/bem';
import { LinkPanel, Heading, Ingress, BodyShort } from '@navikt/ds-react';
import moment from 'moment';
import { Fragment, FunctionComponent, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import './AvtalekortMobil.less';
import { avtaleStatusTekst } from '@/messages';

const cls = BEMHelper('avtalekortMobil');

Expand Down Expand Up @@ -43,7 +44,7 @@ const AvtalekortMobil: FunctionComponent<{
e.preventDefault();
} else {
navigate({
pathname: pathTilAvtaleNy(avtale.id),
pathname: generatePath(Path.AVTALE, { avtaleId: avtale.id }),
search: window.location.search,
});
}
Expand Down
11 changes: 6 additions & 5 deletions src/AvtaleOversikt/LesMerOmLøsningen/LesMerOmLøsningen.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import Info from '@/assets/ikoner/info.svg?react';
import { pathTilInformasjonssideInnloggetNy } from '@/paths';
import BEMHelper from '@/utils/bem';
import { LinkPanel, BodyShort } from '@navikt/ds-react';
import React, { FunctionComponent } from 'react';
import { LinkPanel, BodyShort } from '@navikt/ds-react';

import './LesMerOmLøsningen.less';
import BEMHelper from '@/utils/bem';
import Info from '@/assets/ikoner/info.svg?react';
import { basename, Path } from '@/Router';

const cls = BEMHelper('les-mer-om-løsningen');

const LesMerOmLøsningen: FunctionComponent = () => (
<>
<LinkPanel href={pathTilInformasjonssideInnloggetNy} className={cls.className}>
<LinkPanel href={`${basename}/${Path.INFORMASJONSSIDE}`} className={cls.className}>
<LinkPanel.Title>
<div style={{ display: 'flex' }}>
<Info width="24" height="24" />
Expand Down
4 changes: 2 additions & 2 deletions src/AvtaleProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ const AvtaleProvider: FunctionComponent<PropsWithChildren> = (props) => {
RestService.hentAvtale(avtaleId).then(setAvtale);

const annullerAvtale = async (annullerGrunn: string): Promise<void> => {
await RestService.annullerAvtale(avtale, annullerGrunn);
const annullertAvtale = await RestService.annullerAvtale(avtale, annullerGrunn);
sendToAmplitude('#tiltak-avtale-annullert');
await hentAvtale();
setAvtale(annullertAvtale);
};

const overtaAvtale = async (): Promise<void> => {
Expand Down
5 changes: 5 additions & 0 deletions src/AvtaleSide/AvtaleFetcher.module.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.container {
display: flex;
justify-content: center;
margin-top: 10rem;
}
48 changes: 32 additions & 16 deletions src/AvtaleSide/AvtaleFetcher.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,44 @@
import { AvtaleContext } from '@/AvtaleProvider';
import amplitude from '@/utils/amplitude';
import React, { FunctionComponent, PropsWithChildren, useContext, useEffect, useState } from 'react';
import React, { FunctionComponent, PropsWithChildren, useEffect, useRef, useState } from 'react';
import { useParams } from 'react-router-dom';

import { useAvtale } from '@/AvtaleProvider';
import amplitude from '@/utils/amplitude';
import { useAsyncError } from '@/komponenter/useError';
import { Loader } from '@navikt/ds-react';

import { container } from './AvtaleFetcher.module.less';

const AvtaleFetcher: FunctionComponent<PropsWithChildren> = (props) => {
const [lastetOk, setLastetOk] = useState<boolean>(false);
const [laster, setLaster] = useState<boolean>(true);
const { avtaleId } = useParams<any>();
const { hentAvtale } = useContext(AvtaleContext);
const { hentAvtale } = useAvtale();
const ref = useRef<string>();
const throwError = useAsyncError();

useEffect(() => {
hentAvtale(avtaleId)
.then(() => {
setLastetOk(true);
const run = async () => {
setLaster(true);
try {
await hentAvtale(avtaleId);
setLaster(false);
amplitude.logEvent('#tiltak-avtale-lastet');
})
.catch((error) => {
setLastetOk(false);
} catch (error) {
amplitude.logEvent('#tiltak-avtale-lastet-feilet');
});
// eslint-disable-next-line
}, [avtaleId]);
throwError(error);
}
};
if (avtaleId !== ref.current) {
run();
}
ref.current = avtaleId;
}, [avtaleId, ref, hentAvtale, setLaster, throwError]);

if (!lastetOk) {
return null;
if (laster) {
return (
<div className={container}>
<Loader variant="neutral" size="xlarge" />
</div>
);
}

return <>{props.children}</>;
Expand Down
Loading

0 comments on commit 9d804ee

Please sign in to comment.