Skip to content

Commit

Permalink
[KAIZEN-0] Hent fnr fra routeparams
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesperpaulsen committed Jan 16, 2024
1 parent ffed5b6 commit ecf67c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/app/Routing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ function Routing() {
path={`${paths.saksdokumentEgetVindu}/:fodselsnummer/`}
render={(routeProps) => <SaksDokumentEgetVindu fnr={routeProps.match.params.fodselsnummer} />}
/>
<SentryRoute path={`${paths.personUri}/:fodselsnummer`} component={Personoversikt} />
<SentryRoute
path={`${paths.personUri}/:fodselsnummer`}
render={(routeProps) => <Personoversikt fnr={routeProps.match.params.fodselsnummer} />}
/>
<SentryRoute component={Startbilde} />
</Switch>
</Suspense>
Expand Down
7 changes: 3 additions & 4 deletions src/app/personside/Personoversikt.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import LyttPåNyttFnrIReduxOgHentAllPersoninfo from '../PersonOppslagHandler/LyttPåNyttFnrIReduxOgHentAllPersoninfo';
import MainLayout from './MainLayout';
import { useFodselsnummer, useOnMount } from '../../utils/customHooks';
import { useOnMount } from '../../utils/customHooks';
import { erGyldigishFnr } from '../../utils/fnr-utils';
import { useHistory } from 'react-router';
import { paths } from '../routes/routing';
Expand All @@ -11,14 +11,13 @@ import tilgangskontroll from '../../rest/resources/tilgangskontrollResource';
import { DialogpanelStateProvider } from '../../context/dialogpanel-state';
import NyIdentModal from './NyIdentModal';

function Personoversikt() {
const fnr = useFodselsnummer();
function Personoversikt({ fnr }: { fnr: string }) {
const history = useHistory();

useOnMount(() => {
if (!erGyldigishFnr(fnr)) {
loggInfo('Ugyldig fnr, redirecter til startside');
history.push(`${paths.basePath}?sokFnr=${fnr}`);
history.push(`${paths.basePath}`);
}
});

Expand Down

0 comments on commit ecf67c3

Please sign in to comment.