Skip to content

Commit 10b3d46

Browse files
committed
Legg til hotkey for å gå til Aktivitetsplan
1 parent b7f04ec commit 10b3d46

File tree

3 files changed

+39
-10
lines changed

3 files changed

+39
-10
lines changed

packages/internarbeidsflate-decorator-v3/src/hooks/useLinkHotkeys.ts

+27-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
import { useEffect } from 'react';
22
import { Hotkey } from '../types/Hotkey';
33
import { Environment } from '../utils/environmentUtils';
4-
import { arenaUrl, fpSakUrl, gosysUrl, pesysUrl } from '../utils/urlUtils';
4+
import {
5+
arenaUrl,
6+
fpSakUrl,
7+
gosysUrl,
8+
pesysUrl,
9+
veilarbpersonflateUrl,
10+
} from '../utils/urlUtils';
511
import { useHotkeyState } from '../states/HotkeyState';
612

713
interface Props {
814
environment: Environment;
915
fnr?: string | undefined | null;
1016
aktoerId?: string | undefined | null;
17+
enhet?: string | undefined | null;
1118
}
1219

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

25-
const generateHotkeys = ({ environment, fnr, aktoerId }: Props): Hotkey[] => [
32+
const generateHotkeys = ({
33+
environment,
34+
enhet,
35+
fnr,
36+
aktoerId,
37+
}: Props): Hotkey[] => [
38+
buildHotkey(
39+
'A',
40+
veilarbpersonflateUrl({ environment, enhet, fnr }),
41+
'Gå til Aktivitetsplan',
42+
),
2643
buildHotkey('G', gosysUrl(environment, fnr), 'Gå til Gosys'),
2744
buildHotkey('I', pesysUrl(environment, fnr), 'Gå til Pesys'),
2845
buildHotkey('P', arenaUrl({ environment, fnr }), 'Gå til Arena'),
2946
buildHotkey('K', fpSakUrl(environment, aktoerId), 'Gå til fpsak'),
3047
];
3148

32-
export const useLinkHotkeys = ({ environment, fnr, aktoerId }: Props) => {
49+
export const useLinkHotkeys = ({
50+
environment,
51+
fnr,
52+
enhet,
53+
aktoerId,
54+
}: Props) => {
3355
const registerHotkeys = useHotkeyState().register;
3456
useEffect(() => {
35-
const hotkeys = generateHotkeys({ environment, fnr, aktoerId });
57+
const hotkeys = generateHotkeys({ environment, fnr, enhet, aktoerId });
3658
registerHotkeys(true, ...hotkeys);
37-
}, [environment, fnr, aktoerId, registerHotkeys]);
59+
}, [environment, fnr, enhet, aktoerId, registerHotkeys]);
3860
};

packages/internarbeidsflate-decorator-v3/src/store/EventHandler.ts

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export class EventHandler extends SubstateHandler {
3636

3737
#onWSMessage = (message: MessageEvent<WebSocketMessage>) => {
3838
const data = message.data;
39-
console.log('Recieved data', data);
4039
if (data === 'NY_AKTIV_BRUKER') {
4140
this.#handleFnrChangedExternally();
4241
} else if (data === 'NY_AKTIV_ENHET') {

packages/internarbeidsflate-decorator-v3/src/utils/urlUtils.ts

+12-4
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export const wsEventDistribusjon = (
105105
environment: Environment,
106106
urlFormat: UrlFormat,
107107
) => {
108-
const subdomain = environment === "prod" ? '' : '.dev'
108+
const subdomain = environment === 'prod' ? '' : '.dev';
109109
switch (urlFormat) {
110110
case 'LOCAL':
111111
return 'ws://localhost:4000/ws/';
@@ -198,6 +198,16 @@ export const arenaUrl = ({
198198
)}.adeo.no/forms/frmservlet?config=${arenaConfig(environment)}`;
199199
};
200200

201+
export const veilarbpersonflateUrl = ({
202+
environment,
203+
enhet,
204+
fnr,
205+
}: Pick<BuildLinksProps, 'environment' | 'enhet' | 'fnr'>) => {
206+
return `https://veilarbpersonflate${naisDomain(environment)}/${
207+
fnr ? fnr : ''
208+
}?enhet=${enhet ? enhet : ''}`;
209+
};
210+
201211
interface BuildLinksProps {
202212
environment: Environment;
203213
urlFormat: UrlFormat;
@@ -223,9 +233,7 @@ export const buildLinks = ({
223233
url: `https://veilarbportefoljeflate${naisDomain(environment)}`,
224234
},
225235
veilarbpersonUrl: {
226-
url: `https://veilarbpersonflate${naisDomain(environment)}/${
227-
fnr ? fnr : ''
228-
}?enhet=${enhet ? enhet : ''}`,
236+
url: veilarbpersonflateUrl({ environment, enhet, fnr }),
229237
},
230238
beslutterUrl: {
231239
url: `https://beslutteroversikt${naisDomain(environment)}`,

0 commit comments

Comments
 (0)