Skip to content

Commit

Permalink
Ikke bruk fnr i dialoglenke
Browse files Browse the repository at this point in the history
  • Loading branch information
tu55eladd committed Aug 18, 2023
1 parent de0a401 commit db86e0a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ interface Props {

const SendEnMeldingKnapp = (props: Props) => {
const { aktivitet } = props;
const fnr = useFnr();
const erVeileder = useErVeileder();
const dialog = useSelector(selectDialogForAktivitetId(aktivitet.id));

Expand All @@ -30,7 +29,7 @@ const SendEnMeldingKnapp = (props: Props) => {
const veilederOnClick = (event: React.MouseEvent) => {
if (erVeileder) {
navigate(hovedsideRoute(), { replace: true });
byttTilDialogFlate({ event, fnr, aktivitetId: aktivitet?.id, dialogId: dialog?.id });
byttTilDialogFlate({ event, aktivitetId: aktivitet?.id, dialogId: dialog?.id });
}
};

Expand All @@ -39,7 +38,7 @@ const SendEnMeldingKnapp = (props: Props) => {
<Button
variant="secondary"
as="a"
href={getDialogLenke({ erVeileder, fnr, aktivitetId: aktivitet.id, dialogId: dialog?.id })}
href={getDialogLenke({ erVeileder, aktivitetId: aktivitet.id, dialogId: dialog?.id })}
icon={<ChatElipsisIcon aria-hidden fontSize="1.5rem" />}
onClick={veilederOnClick}
>
Expand Down
12 changes: 5 additions & 7 deletions src/moduler/dialog/DialogFlateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ export const byttTilDialogFlate = ({
event,
aktivitetId,
dialogId,
fnr,
}: {
event: MouseEvent;
fnr?: string;
aktivitetId?: string;
dialogId?: string;
}) => {
event.preventDefault();
window.history.pushState('', 'Dialog', getDialogLenke({ erVeileder: true, fnr, aktivitetId, dialogId }));
window.history.pushState('', 'Dialog', getDialogLenke({ erVeileder: true, aktivitetId, dialogId }));
window.dispatchEvent(
new CustomEvent<DialogEventDetails>('visDialog', {
detail: {
Expand All @@ -32,7 +31,6 @@ export const byttTilDialogFlate = ({

export const getDialogLenke = ({
dialogId,
fnr,
aktivitetId,
erVeileder,
}: {
Expand All @@ -41,14 +39,14 @@ export const getDialogLenke = ({
aktivitetId?: string;
dialogId?: string;
}) => {
if (erVeileder && fnr) {
if (erVeileder) {
if (dialogId) {
return `/${fnr}/${dialogId}`;
return `/${dialogId}`;
}
if (aktivitetId) {
return `/${fnr}/ny?aktivitetId=${aktivitetId}`;
return `/ny?aktivitetId=${aktivitetId}`;
}
return `/${fnr}`;
return `/`;
} else {
if (dialogId) {
return `${ARBEIDSRETTET_DIALOG_URL}/${dialogId}`;
Expand Down
9 changes: 2 additions & 7 deletions src/moduler/dialog/DialogLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ interface Props {
const LenkeTilDialog = (props: Props) => {
const { className, dialogId, aktivitetId, hidden, children } = props;

const fnr = useFnr();
const navigate = useNavigate();
const erVeileder = useErVeileder();
const { hovedsideRoute } = useRoutes();

const internalOnClick = (event: MouseEvent) => {
if (erVeileder) {
navigate(hovedsideRoute(), { replace: true });
byttTilDialogFlate({ event, fnr, aktivitetId, dialogId });
byttTilDialogFlate({ event, aktivitetId, dialogId });
}
};

Expand All @@ -33,11 +32,7 @@ const LenkeTilDialog = (props: Props) => {
}

return (
<a
href={getDialogLenke({ erVeileder, fnr, aktivitetId, dialogId })}
onClick={internalOnClick}
className={className}
>
<a href={getDialogLenke({ erVeileder, aktivitetId, dialogId })} onClick={internalOnClick} className={className}>
{children}
</a>
);
Expand Down

0 comments on commit db86e0a

Please sign in to comment.