Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legg til hotkey for å gå til Aktivitetsplan #402

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { useEffect } from 'react';
import { Hotkey } from '../types/Hotkey';
import { Environment } from '../utils/environmentUtils';
import { arenaUrl, fpSakUrl, gosysUrl, pesysUrl } from '../utils/urlUtils';
import {
arenaUrl,
fpSakUrl,
gosysUrl,
pesysUrl,
veilarbpersonflateUrl,
} from '../utils/urlUtils';
import { useHotkeyState } from '../states/HotkeyState';

interface Props {
environment: Environment;
fnr?: string | undefined | null;
aktoerId?: string | undefined | null;
enhet?: string | undefined | null;
}

const openurl = (url: string) => () => window.open(url, '_blank');
Expand All @@ -22,17 +29,32 @@ const buildHotkey = (
description,
});

const generateHotkeys = ({ environment, fnr, aktoerId }: Props): Hotkey[] => [
const generateHotkeys = ({
environment,
enhet,
fnr,
aktoerId,
}: Props): Hotkey[] => [
buildHotkey(
'A',
veilarbpersonflateUrl({ environment, enhet, fnr }),
'Gå til Aktivitetsplan',
),
buildHotkey('G', gosysUrl(environment, fnr), 'Gå til Gosys'),
buildHotkey('I', pesysUrl(environment, fnr), 'Gå til Pesys'),
buildHotkey('P', arenaUrl({ environment, fnr }), 'Gå til Arena'),
buildHotkey('K', fpSakUrl(environment, aktoerId), 'Gå til fpsak'),
];

export const useLinkHotkeys = ({ environment, fnr, aktoerId }: Props) => {
export const useLinkHotkeys = ({
environment,
fnr,
enhet,
aktoerId,
}: Props) => {
const registerHotkeys = useHotkeyState().register;
useEffect(() => {
const hotkeys = generateHotkeys({ environment, fnr, aktoerId });
const hotkeys = generateHotkeys({ environment, fnr, enhet, aktoerId });
registerHotkeys(true, ...hotkeys);
}, [environment, fnr, aktoerId, registerHotkeys]);
}, [environment, fnr, enhet, aktoerId, registerHotkeys]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export class EventHandler extends SubstateHandler {

#onWSMessage = (message: MessageEvent<WebSocketMessage>) => {
const data = message.data;
console.log('Recieved data', data);
if (data === 'NY_AKTIV_BRUKER') {
this.#handleFnrChangedExternally();
} else if (data === 'NY_AKTIV_ENHET') {
Expand Down
16 changes: 12 additions & 4 deletions packages/internarbeidsflate-decorator-v3/src/utils/urlUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const wsEventDistribusjon = (
environment: Environment,
urlFormat: UrlFormat,
) => {
const subdomain = environment === "prod" ? '' : '.dev'
const subdomain = environment === 'prod' ? '' : '.dev';
switch (urlFormat) {
case 'LOCAL':
return 'ws://localhost:4000/ws/';
Expand Down Expand Up @@ -198,6 +198,16 @@ export const arenaUrl = ({
)}.adeo.no/forms/frmservlet?config=${arenaConfig(environment)}`;
};

export const veilarbpersonflateUrl = ({
environment,
enhet,
fnr,
}: Pick<BuildLinksProps, 'environment' | 'enhet' | 'fnr'>) => {
return `https://veilarbpersonflate${naisDomain(environment)}/${
fnr ? fnr : ''
}?enhet=${enhet ? enhet : ''}`;
};

interface BuildLinksProps {
environment: Environment;
urlFormat: UrlFormat;
Expand All @@ -223,9 +233,7 @@ export const buildLinks = ({
url: `https://veilarbportefoljeflate${naisDomain(environment)}`,
},
veilarbpersonUrl: {
url: `https://veilarbpersonflate${naisDomain(environment)}/${
fnr ? fnr : ''
}?enhet=${enhet ? enhet : ''}`,
url: veilarbpersonflateUrl({ environment, enhet, fnr }),
},
beslutterUrl: {
url: `https://beslutteroversikt${naisDomain(environment)}`,
Expand Down
Loading