wcz-test 7.20.0 → 7.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,34 @@
1
+ import { createContext as u, useState as f, useEffect as p } from "react";
2
+ import { c as d } from "./compiler-runtime-BNHg76kC.js";
3
+ import { EventType as b } from "@azure/msal-browser";
4
+ import { p as r, d as E, b as C } from "./utils-DOb0-V1G.js";
5
+ const U = u(null), _ = () => {
6
+ const t = d.c(3), [i, m] = f(null);
7
+ let c;
8
+ t[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (c = () => {
9
+ const e = r.getActiveAccount();
10
+ if (e?.idToken) {
11
+ const n = E(e.idToken), a = C(n);
12
+ m(a);
13
+ }
14
+ }, t[0] = c) : c = t[0];
15
+ const l = c;
16
+ let o, s;
17
+ return t[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (o = () => {
18
+ l();
19
+ const e = r.addEventCallback((n) => {
20
+ if (n.eventType === b.ACQUIRE_TOKEN_SUCCESS) {
21
+ const a = n.payload;
22
+ a.account && (r.setActiveAccount(a.account), l());
23
+ }
24
+ });
25
+ return () => {
26
+ e && r.removeEventCallback(e);
27
+ };
28
+ }, s = [l], t[1] = o, t[2] = s) : (o = t[1], s = t[2]), p(o, s), i;
29
+ };
30
+ export {
31
+ U as N,
32
+ _ as u
33
+ };
34
+ //# sourceMappingURL=UseUser-BHnbzn4s.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseUser-BHnbzn4s.js","sources":["../src/contexts/NotificationContext.tsx","../src/hooks/UseUser.ts"],"sourcesContent":["import { createContext } from \"react\";\r\nimport type { AlertColor } from \"@mui/material/Alert\";\r\n\r\nexport interface NotificationOptions {\r\n severity?: AlertColor;\r\n autoHideDuration?: number;\r\n}\r\n\r\nexport interface NotificationContextValue {\r\n notify: (message: string, options?: NotificationOptions) => void;\r\n}\r\n\r\nexport const NotificationContext = createContext<NotificationContextValue | null>(null);\r\n","import type { AuthenticationResult, EventMessage } from \"@azure/msal-browser\";\r\nimport { EventType } from \"@azure/msal-browser\";\r\nimport { useEffect, useState } from \"react\";\r\nimport { pca } from \"~/lib/auth/msalClient\";\r\nimport { buildUser, decodeJwt } from \"~/lib/utils\";\r\nimport type { User } from \"~/models/User\";\r\n\r\nexport const useUser = () => {\r\n const [user, setUser] = useState<User | null>(null);\r\n\r\n const processAccount = () => {\r\n const account = pca.getActiveAccount();\r\n if (account?.idToken) {\r\n const claims = decodeJwt(account.idToken);\r\n const builtUser = buildUser(claims);\r\n setUser(builtUser);\r\n }\r\n };\r\n\r\n useEffect(() => {\r\n processAccount();\r\n\r\n const callbackId = pca.addEventCallback((event: EventMessage) => {\r\n if (event.eventType === EventType.ACQUIRE_TOKEN_SUCCESS) {\r\n const payload = event.payload as AuthenticationResult;\r\n if (payload.account) {\r\n pca.setActiveAccount(payload.account);\r\n processAccount();\r\n }\r\n }\r\n });\r\n\r\n return () => {\r\n if (callbackId) {\r\n pca.removeEventCallback(callbackId);\r\n }\r\n };\r\n }, [processAccount]);\r\n\r\n return user;\r\n};\r\n"],"names":["NotificationContext","createContext","useUser","$","_c","user","setUser","useState","t0","Symbol","for","account","pca","getActiveAccount","idToken","claims","decodeJwt","builtUser","buildUser","processAccount","t1","t2","callbackId","addEventCallback","event","eventType","EventType","ACQUIRE_TOKEN_SUCCESS","payload","setActiveAccount","removeEventCallback","useEffect"],"mappings":";;;;AAYO,MAAMA,IAAsBC,EAA+C,IAAI,GCLzEC,IAAUA,MAAA;AAAA,QAAAC,IAAAC,EAAAA,EAAA,CAAA,GACnB,CAAAC,GAAAC,CAAA,IAAwBC,EAAsB,IAAI;AAAE,MAAAC;AAAA,EAAAL,EAAA,CAAA,MAAAM,uBAAAC,IAAA,2BAAA,KAE7BF,IAAAA,MAAA;AACnB,UAAAG,IAAgBC,EAAGC,iBAAAA;AACnB,QAAIF,GAAOG,SAAS;AAChB,YAAAC,IAAeC,EAAUL,EAAOG,OAAQ,GACxCG,IAAkBC,EAAUH,CAAM;AAClCT,MAAAA,EAAQW,CAAS;AAAA,IAAC;AAAA,EACrB,GACJd,OAAAK,KAAAA,IAAAL,EAAA,CAAA;AAPD,QAAAgB,IAAuBX;AAOrB,MAAAY,GAAAC;AAAA,SAAAlB,EAAA,CAAA,MAAAM,uBAAAC,IAAA,2BAAA,KAEQU,IAAAA,MAAA;AACND,IAAAA,EAAAA;AAEA,UAAAG,IAAmBV,EAAGW,iBAAkBC,CAAAA,MAAA;AACpC,UAAIA,EAAKC,cAAeC,EAASC,uBAAsB;AACnD,cAAAC,IAAgBJ,EAAKI;AACrB,QAAIA,EAAOjB,YACPC,EAAGiB,iBAAkBD,EAAOjB,OAAQ,GACpCQ,EAAAA;AAAAA,MACH;AAAA,IACJ,CACJ;AAAE,WAEI,MAAA;AACH,MAAIG,KACAV,EAAGkB,oBAAqBR,CAAU;AAAA,IACrC;AAAA,EACJ,GACFD,IAAA,CAACF,CAAc,GAAChB,OAAAiB,GAAAjB,OAAAkB,MAAAD,IAAAjB,EAAA,CAAA,GAAAkB,IAAAlB,EAAA,CAAA,IAlBnB4B,EAAUX,GAkBPC,CAAgB,GAEZhB;AAAI;"}
@@ -1,7 +1,9 @@
1
1
  import { FC, ReactNode } from 'react';
2
+ import { LayoutOptions } from '../../models/LayoutOptions';
2
3
  import { Navigation } from '../../models/Navigation';
3
4
  interface LayoutProps {
4
5
  navigation: Navigation | undefined;
6
+ options: LayoutOptions | undefined;
5
7
  children: ReactNode;
6
8
  }
7
9
  export declare const Layout: FC<LayoutProps>;
@@ -1,2 +1,2 @@
1
1
  import { User } from '../models/User';
2
- export declare const useUser: () => User;
2
+ export declare const useUser: () => User | null;
package/dist/hooks.js CHANGED
@@ -7,8 +7,8 @@ import { f as G } from "./utils-DOb0-V1G.js";
7
7
  import { DatePicker as Qe, DateRangePicker as Xe, TimePicker as Ye, TimeRangePicker as et, DateTimePicker as tt, DateTimeRangePicker as rt } from "@mui/x-date-pickers-pro";
8
8
  import ne, { useRef as te, useState as De, useEffect as oe, useMemo as at, useLayoutEffect as nt, useContext as it } from "react";
9
9
  import { u as gr, a as xr } from "./DialogsHooks-BFlSkOtF.js";
10
- import { N as lt } from "./UseUser-BWVpi0Sa.js";
11
- import { u as br } from "./UseUser-BWVpi0Sa.js";
10
+ import { N as lt } from "./UseUser-BHnbzn4s.js";
11
+ import { u as br } from "./UseUser-BHnbzn4s.js";
12
12
  const ot = (t) => {
13
13
  const e = $.c(23);
14
14
  let r, n;