-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IS-2300: internarbeidsflate-decorator-v3
- Loading branch information
1 parent
3af9dfc
commit d826743
Showing
16 changed files
with
171 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { post } from "@/api/axios"; | ||
import { MODIACONTEXTHOLDER_ROOT } from "@/api/constants"; | ||
import { useMutation } from "@tanstack/react-query"; | ||
|
||
const NY_AKTIV_BRUKER = "NY_AKTIV_BRUKER"; | ||
|
||
export const useAktivBruker = () => | ||
useMutation({ | ||
mutationFn: (fnr: string) => | ||
post(`${MODIACONTEXTHOLDER_ROOT}/context`, { | ||
verdi: fnr, | ||
eventType: NY_AKTIV_BRUKER, | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,67 @@ | ||
interface TogglesConfig { | ||
visVeileder: boolean; | ||
export interface DecoratorProps { | ||
enhet?: string | undefined; // Konfigurasjon av enhet-kontekst | ||
accessToken?: string | undefined; // Manuell innsending av JWT, settes som Authorization-header. Om null sendes cookies vha credentials: 'include' | ||
fnr?: string | undefined; // Konfigurasjon av fødselsnummer-kontekst | ||
userKey?: string | undefined; // Om man ikke ønsker å bruke fnr i urler, kan andre apper kalle contextholder for å generere en midlertidig kode. Hvis App A skal navigere til App B som har dekoratøren, må App A først sende en post request til /fnr-code/generate med {fnr: string} i bodyen, dette returnerer {fnr: string, code: string} til App A. App A kan så navigere til App B og sende med denne koden. App B kan så sende den koden inn til dekoratøren i userKey propen og så henter dekoratøren fnr for den koden fra contextholderen. | ||
enableHotkeys?: boolean | undefined; // Aktivere hurtigtaster | ||
fetchActiveEnhetOnMount?: boolean | undefined; // Om enhet er undefined fra container appen, og denne er satt til true, henter den sist aktiv enhet og bruker denne. | ||
fetchActiveUserOnMount?: boolean | undefined; // Om fnr er undefined fra container appen, og denne er satt til true for at den skal hente siste aktiv fnr. | ||
onEnhetChanged: (enhetId?: string | null, enhet?: Enhet) => void; // Kalles når enheten endres | ||
onFnrChanged: (fnr?: string | null) => void; // Kalles når fnr enheten endres | ||
onLinkClick?: (link: { text: string; url: string }) => void; // Kan brukes for å legge til callbacks ved klikk på lenker i menyen. Merk at callbacken ikke kan awaites og man må selv håndtere at siden lukkes. Nyttig for å f.eks tracke navigasjon events i amplitude | ||
appName: string; // Navn på applikasjonen | ||
hotkeys?: Hotkey[]; // Konfigurasjon av hurtigtaster | ||
markup?: Markup; // Egen HTML | ||
showEnheter: boolean; // Vis enheter | ||
showSearchArea: boolean; // Vis søkefelt | ||
showHotkeys: boolean; // Vis hurtigtaster | ||
environment: Environment; // Miljø som skal brukes. | ||
urlFormat: UrlFormat; // URL format | ||
proxy?: string | undefined; // Manuell overstyring av urlene til BFFs. Gjør alle kall til relativt path hvis true, og bruker verdien som domene om satt til en string. Default: false | ||
} | ||
|
||
interface Markup { | ||
etterSokefelt?: string; | ||
export interface Markup { | ||
etterSokefelt?: string; // Gir muligheten for sende inn egen html som blir en del av dekoratøren | ||
} | ||
|
||
export interface ControlledContextvalue<T> extends BaseContextvalue<T> { | ||
value?: string; | ||
} | ||
interface UncontrolledContextvalue<T> extends BaseContextvalue<T> { | ||
initialValue?: string; | ||
export interface Enhet { | ||
readonly enhetId: string; | ||
readonly navn: string; | ||
} | ||
|
||
interface BaseContextvalue<T> { | ||
display: T; | ||
onChange(value?: string): void; | ||
skipModal?: boolean; | ||
ignoreWsEvents?: boolean; | ||
} | ||
// Miljø | ||
export type Environment = | ||
| "q0" | ||
| "q1" | ||
| "q2" | ||
| "q3" | ||
| "q4" | ||
| "prod" | ||
| "local" | ||
| "mock"; | ||
|
||
export type Contextvalue<T> = | ||
| ControlledContextvalue<T> | ||
| UncontrolledContextvalue<T>; | ||
export type UrlFormat = "LOCAL" | "NAV_NO" | "ANSATT"; // UrlFormat. Brukes om proxy ikke er satt & i url til websocket. | ||
|
||
export enum EnhetDisplay { | ||
ENHET = "ENHET", | ||
ENHET_VALG = "ENHET_VALG", | ||
export interface HotkeyObject { | ||
char: string; | ||
altKey?: boolean; | ||
ctrlKey?: boolean; | ||
metaKey?: boolean; | ||
shiftKey?: boolean; | ||
} | ||
|
||
export enum FnrDisplay { | ||
SOKEFELT = "SOKEFELT", | ||
export interface HotkeyDescription { | ||
key: HotkeyObject; | ||
description: string; | ||
forceOverride?: boolean; | ||
} | ||
|
||
type EnhetContextvalue = Contextvalue<EnhetDisplay>; | ||
type FnrContextvalue = Contextvalue<FnrDisplay>; | ||
type ProxyConfig = boolean | string; | ||
export interface ActionHotKey extends HotkeyDescription { | ||
action(event: KeyboardEvent): void; | ||
} | ||
|
||
export interface DecoratorProps { | ||
appname: string; | ||
fnr?: FnrContextvalue; | ||
enhet?: EnhetContextvalue; | ||
toggles?: TogglesConfig; | ||
markup?: Markup; | ||
useProxy?: ProxyConfig; | ||
accessToken?: string; | ||
export interface DocumentingHotKey extends HotkeyDescription { | ||
documentationOnly: boolean; | ||
} | ||
|
||
export type Hotkey = ActionHotKey | DocumentingHotKey; |
Oops, something went wrong.