Skip to content

Commit

Permalink
IS-27IS-2792-measure-apne-enkeltperson
Browse files Browse the repository at this point in the history
  • Loading branch information
ingring committed Nov 6, 2024
1 parent 93f3981 commit f6b6e22
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/components/LinkSyfomodiaperson.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React, { ReactElement } from 'react';
import Lenke from 'nav-frontend-lenker';
import { PersonData } from '@/api/types/personregisterTypes';
import { linkToNewHostAndPath, Subdomain } from '@/utils/miljoUtil';
import { Labels } from '@/components/Labels';
import { useAktivBruker } from '@/data/modiacontext/useAktivBruker';
import { Link } from '@navikt/ds-react';
import * as Amplitude from '@/utils/amplitude';
import { EventType } from '@/utils/amplitude';

export const lenkeTilModia = (personData: PersonData) => {
export function lenkeTilModia(personData: PersonData): string {
let path = `/sykefravaer`;
const isGoingToMoteoversikt =
personData.harMotebehovUbehandlet ||
Expand Down Expand Up @@ -42,7 +44,17 @@ export const lenkeTilModia = (personData: PersonData) => {
}

return linkToNewHostAndPath(Subdomain.SYFOMODIAPERSON, path);
};
}

function logNavigation(destinasjon: string) {
Amplitude.logEvent({
type: EventType.Navigation,
data: {
lenketekst: 'personnavn',
destinasjon: destinasjon,
},
});
}

interface Props {
personData: PersonData;
Expand All @@ -59,22 +71,24 @@ export function LinkSyfomodiaperson({
const onPersonClick = () => {
aktivBruker.mutate(personident, {
onSuccess: () => {
window.location.href = lenkeTilModia(personData);
const destinasjon = lenkeTilModia(personData);
logNavigation(destinasjon);
window.location.href = destinasjon;
},
});
};

return (
<div className="flex items-center gap-2">
<Lenke
<Link
onClick={(event) => {
event.preventDefault();
onPersonClick();
}}
href={lenkeTilModia(personData)}
>
{linkText}
</Lenke>
</Link>
<Labels personData={personData} />
</div>
);
Expand Down

0 comments on commit f6b6e22

Please sign in to comment.