@m4l/layouts 0.1.38 → 0.1.40

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.
Files changed (37) hide show
  1. package/components/BaseModule/index.6309486a.js +24 -24
  2. package/components/BaseModule/index.d.ts +2 -1
  3. package/components/MFHostApp/index.420c2626.js +58 -58
  4. package/components/MFHostApp/index.d.ts +2 -1
  5. package/components/MFIsolationApp/index.d.ts +2 -1
  6. package/components/MFIsolationApp/index.e36cf308.js +175 -0
  7. package/components/MFIsolationApp/subcomponents/MFAuthApp/index.d.ts +2 -1
  8. package/components/{index.604759d6.js → index.aeb3cf83.js} +1 -1
  9. package/contexts/AuthContext/index.6f966215.js +118 -88
  10. package/contexts/AuthContext/index.d.ts +1 -1
  11. package/hooks/index.a0c767ed.js +4 -0
  12. package/hooks/useAuth/index.cb6a3420.js +7 -7
  13. package/hooks/useMasterDetail/index.927c0c26.js +6 -0
  14. package/hooks/useModule/index.edcd7b28.js +11 -0
  15. package/index.js +27 -27
  16. package/layouts/MasterDetailLayout/contexts/MasterDetailContext/index.d.ts +1 -1
  17. package/layouts/MasterDetailLayout/index.bca0fce5.js +136 -0
  18. package/layouts/MasterDetailLayout/index.d.ts +2 -1
  19. package/layouts/ModuleLayout/contexts/ModuleContext/index.d.ts +1 -1
  20. package/layouts/ModuleLayout/index.850f7dcf.js +118 -0
  21. package/layouts/ModuleLayout/subcomponents/InnerModule/styles.d.ts +3 -0
  22. package/layouts/NoAuthModuleLayout/index.d.ts +2 -1
  23. package/layouts/NoAuthModuleLayout/index.eabf38c1.js +179 -146
  24. package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/index.d.ts +2 -1
  25. package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/styles.d.ts +2 -0
  26. package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/DesktopContent/index.d.ts +2 -1
  27. package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/DesktopContent/styles.d.ts +9 -0
  28. package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/MobileContent/index.d.ts +2 -1
  29. package/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/MobileContent/styles.d.ts +9 -0
  30. package/layouts/{index.3e2d546f.js → index.07aacf57.js} +2 -2
  31. package/package.json +2 -1
  32. package/components/MFIsolationApp/index.ed197bc0.js +0 -152
  33. package/hooks/index.18c6b299.js +0 -4
  34. package/hooks/useMasterDetail/index.50331312.js +0 -6
  35. package/hooks/useModule/index.35cc5fe0.js +0 -11
  36. package/layouts/MasterDetailLayout/index.2c363c7a.js +0 -109
  37. package/layouts/ModuleLayout/index.90b4dc8e.js +0 -103
@@ -1,27 +1,27 @@
1
- import { ModalProvider as s } from "@m4l/components";
2
- import { FlagsProvider as u, ModuleDictionaryProvider as c, ModuleSkeletonProvider as m, ModulePrivilegesProvider as a } from "@m4l/core";
3
- import { jsx as e } from "react/jsx-runtime";
4
- function h(r) {
1
+ import { ModalProvider } from "@m4l/components";
2
+ import { FlagsProvider, ModuleDictionaryProvider, ModuleSkeletonProvider, ModulePrivilegesProvider } from "@m4l/core";
3
+ import { jsx } from "react/jsx-runtime";
4
+ function BaseModule(props) {
5
5
  const {
6
- children: o,
7
- moduleId: i,
8
- moduleNameField: l,
9
- skeletonFlags: d,
10
- privileges: n,
11
- componentsDictionary: t
12
- } = r;
13
- return /* @__PURE__ */ e(u, {
14
- children: /* @__PURE__ */ e(c, {
15
- isAuth: !0,
16
- moduleId: i,
17
- moduleNameField: l,
18
- componentsDictionary: t,
19
- children: /* @__PURE__ */ e(m, {
20
- flags: d,
21
- children: /* @__PURE__ */ e(a, {
22
- queryPrivileges: n,
23
- children: /* @__PURE__ */ e(s, {
24
- children: o
6
+ children,
7
+ moduleId,
8
+ moduleNameField,
9
+ skeletonFlags,
10
+ privileges,
11
+ componentsDictionary
12
+ } = props;
13
+ return /* @__PURE__ */ jsx(FlagsProvider, {
14
+ children: /* @__PURE__ */ jsx(ModuleDictionaryProvider, {
15
+ isAuth: true,
16
+ moduleId,
17
+ moduleNameField,
18
+ componentsDictionary,
19
+ children: /* @__PURE__ */ jsx(ModuleSkeletonProvider, {
20
+ flags: skeletonFlags,
21
+ children: /* @__PURE__ */ jsx(ModulePrivilegesProvider, {
22
+ queryPrivileges: privileges,
23
+ children: /* @__PURE__ */ jsx(ModalProvider, {
24
+ children
25
25
  })
26
26
  })
27
27
  })
@@ -29,5 +29,5 @@ function h(r) {
29
29
  });
30
30
  }
31
31
  export {
32
- h as B
32
+ BaseModule as B
33
33
  };
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { BaseModuleProps } from './types';
2
- export declare function BaseModule(props: BaseModuleProps): JSX.Element;
3
+ export declare function BaseModule(props: BaseModuleProps): import("react").JSX.Element;
3
4
  export default BaseModule;
@@ -1,61 +1,61 @@
1
- import { unstable_HistoryRouter as p } from "react-router-dom";
2
- import { EnvironmentProvider as v, HostToolsProvider as M, NetworkProvider as P, DomainCountryProvider as f } from "@m4l/core";
3
- import { LocalesProvider as b, HostThemeProvider as T, FormatterProvider as g } from "@m4l/graphics";
4
- import { WindowToolsMFProvider as E, DynamicMFParmsProvider as H } from "@m4l/components";
5
- import { B as _ } from "../BaseModule/index.6309486a.js";
6
- import { jsx as r } from "react/jsx-runtime";
7
- function L(t) {
1
+ import { unstable_HistoryRouter } from "react-router-dom";
2
+ import { EnvironmentProvider, HostToolsProvider, NetworkProvider, DomainCountryProvider } from "@m4l/core";
3
+ import { LocalesProvider, HostThemeProvider, FormatterProvider } from "@m4l/graphics";
4
+ import { WindowToolsMFProvider, DynamicMFParmsProvider } from "@m4l/components";
5
+ import { B as BaseModule } from "../BaseModule/index.6309486a.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ function MFHostApp(props) {
8
8
  const {
9
- children: n,
10
- currentLocale: d,
11
- hostTheme: m,
12
- environment: s,
13
- hostTools: e,
14
- axiosOperation: c,
15
- formatters: o,
16
- moduleId: l,
17
- moduleNameField: a,
18
- skeletonFlags: u,
19
- privileges: h,
20
- componentsDictionary: y,
21
- dynamicMFStore: i,
22
- windowTools: F
23
- } = t;
24
- return /* @__PURE__ */ r(v, {
25
- ...s,
26
- children: /* @__PURE__ */ r(M, {
27
- ...e,
28
- children: /* @__PURE__ */ r(P, {
29
- axiosOperation: c,
30
- children: /* @__PURE__ */ r(b, {
31
- isMicroFrontEnd: !0,
32
- localeHost: d,
33
- children: /* @__PURE__ */ r(T, {
34
- isMicroFrontEnd: !0,
35
- ...m,
36
- children: /* @__PURE__ */ r(p, {
37
- history: e.history,
38
- children: /* @__PURE__ */ r(f, {
39
- isMicroFrontEnd: !0,
40
- id: i?.getState().dynamicMFParameters?.id || 1,
41
- currency: o.currencyFormatter.code,
42
- currency_decimal_digits: o.currencyFormatter.decimalDigits,
43
- decimal_symbol: o.numberFormatter.decimalSymbol,
44
- thousands_symbol: o.numberFormatter.thousandsSymbol,
45
- children: /* @__PURE__ */ r(_, {
46
- moduleId: l,
47
- moduleNameField: a,
48
- componentsDictionary: y,
49
- skeletonFlags: u,
50
- privileges: h,
51
- children: /* @__PURE__ */ r(g, {
52
- isMicroFrontEnd: !0,
53
- ...o,
54
- children: /* @__PURE__ */ r(E, {
55
- ...F,
56
- children: /* @__PURE__ */ r(H, {
57
- store: i,
58
- children: n
9
+ children,
10
+ currentLocale,
11
+ hostTheme,
12
+ environment,
13
+ hostTools,
14
+ axiosOperation,
15
+ formatters,
16
+ moduleId,
17
+ moduleNameField,
18
+ skeletonFlags,
19
+ privileges,
20
+ componentsDictionary,
21
+ dynamicMFStore,
22
+ windowTools
23
+ } = props;
24
+ return /* @__PURE__ */ jsx(EnvironmentProvider, {
25
+ ...environment,
26
+ children: /* @__PURE__ */ jsx(HostToolsProvider, {
27
+ ...hostTools,
28
+ children: /* @__PURE__ */ jsx(NetworkProvider, {
29
+ axiosOperation,
30
+ children: /* @__PURE__ */ jsx(LocalesProvider, {
31
+ isMicroFrontEnd: true,
32
+ localeHost: currentLocale,
33
+ children: /* @__PURE__ */ jsx(HostThemeProvider, {
34
+ isMicroFrontEnd: true,
35
+ ...hostTheme,
36
+ children: /* @__PURE__ */ jsx(unstable_HistoryRouter, {
37
+ history: hostTools.history,
38
+ children: /* @__PURE__ */ jsx(DomainCountryProvider, {
39
+ isMicroFrontEnd: true,
40
+ id: dynamicMFStore?.getState().dynamicMFParameters?.id || 1,
41
+ currency: formatters.currencyFormatter.code,
42
+ currency_decimal_digits: formatters.currencyFormatter.decimalDigits,
43
+ decimal_symbol: formatters.numberFormatter.decimalSymbol,
44
+ thousands_symbol: formatters.numberFormatter.thousandsSymbol,
45
+ children: /* @__PURE__ */ jsx(BaseModule, {
46
+ moduleId,
47
+ moduleNameField,
48
+ componentsDictionary,
49
+ skeletonFlags,
50
+ privileges,
51
+ children: /* @__PURE__ */ jsx(FormatterProvider, {
52
+ isMicroFrontEnd: true,
53
+ ...formatters,
54
+ children: /* @__PURE__ */ jsx(WindowToolsMFProvider, {
55
+ ...windowTools,
56
+ children: /* @__PURE__ */ jsx(DynamicMFParmsProvider, {
57
+ store: dynamicMFStore,
58
+ children
59
59
  })
60
60
  })
61
61
  })
@@ -69,5 +69,5 @@ function L(t) {
69
69
  });
70
70
  }
71
71
  export {
72
- L as M
72
+ MFHostApp as M
73
73
  };
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { MFHostAppProps } from './types';
2
- export declare function MFHostApp(props: MFHostAppProps): JSX.Element;
3
+ export declare function MFHostApp(props: MFHostAppProps): import("react").JSX.Element;
3
4
  export default MFHostApp;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { MFIsolationAppProps } from './types';
2
- export declare function MFIsolationApp(props: MFIsolationAppProps): JSX.Element;
3
+ export declare function MFIsolationApp(props: MFIsolationAppProps): import("react").JSX.Element;
3
4
  export default MFIsolationApp;
@@ -0,0 +1,175 @@
1
+ import { useEffect, useMemo, useCallback } from "react";
2
+ import { unstable_HistoryRouter } from "react-router-dom";
3
+ import { ToastContainer, toast } from "react-toastify";
4
+ import { HostThemeProvider, GlobalStyles, FormatterProvider, LocalesProvider, getLocaleFromNetwork } from "@m4l/graphics";
5
+ import { A as AuthProvider } from "../../contexts/AuthContext/index.6f966215.js";
6
+ import { DomainCountryProvider, EnvironmentProvider, HostToolsProvider, NetworkProvider, axiosOperation } from "@m4l/core";
7
+ import { createBrowserHistory } from "history";
8
+ import EventEmitter from "eventemitter3";
9
+ import { format } from "date-fns";
10
+ import { defaultThemeOptions, fnComponentsOverrides } from "@m4l/styles";
11
+ import { u as useAuth } from "../../hooks/useAuth/index.cb6a3420.js";
12
+ import { jsx, jsxs } from "react/jsx-runtime";
13
+ import NProgress from "nprogress";
14
+ import { B as BaseModule } from "../BaseModule/index.6309486a.js";
15
+ import { AreasProvider } from "@m4l/components";
16
+ function MFAuthApp(props) {
17
+ const {
18
+ children,
19
+ user,
20
+ pwd
21
+ } = props;
22
+ const {
23
+ isAuthenticated,
24
+ isInitialized,
25
+ login,
26
+ user: authUser
27
+ } = useAuth();
28
+ useEffect(() => {
29
+ if (isInitialized && isAuthenticated === false) {
30
+ login(user, pwd, false);
31
+ }
32
+ }, [isInitialized, isAuthenticated]);
33
+ if (!isAuthenticated)
34
+ return /* @__PURE__ */ jsx("div", {
35
+ children: "Pendiente x atenticar"
36
+ });
37
+ const domianCountry = {
38
+ id: 1,
39
+ currency: "USD",
40
+ currency_decimal_digits: 2,
41
+ decimal_symbol: ".",
42
+ thousands_symbol: ","
43
+ };
44
+ if (authUser?.domain_country) {
45
+ domianCountry.id = authUser?.domain_country.id ?? domianCountry.id;
46
+ domianCountry.currency = authUser?.domain_country.currency ?? domianCountry.currency;
47
+ domianCountry.currency_decimal_digits = authUser?.domain_country.currency_decimal_digits ?? domianCountry.currency_decimal_digits;
48
+ domianCountry.decimal_symbol = authUser?.domain_country.decimal_symbol ?? domianCountry.decimal_symbol;
49
+ domianCountry.thousands_symbol = authUser?.domain_country?.thousands_symbol ?? domianCountry.thousands_symbol;
50
+ }
51
+ return /* @__PURE__ */ jsxs(HostThemeProvider, {
52
+ hostThemeOptions: defaultThemeOptions,
53
+ fnComponentsOverrides,
54
+ isMicroFrontEnd: true,
55
+ children: [/* @__PURE__ */ jsx(ToastContainer, {}), /* @__PURE__ */ jsx(GlobalStyles, {}), /* @__PURE__ */ jsx(DomainCountryProvider, {
56
+ ...domianCountry,
57
+ isMicroFrontEnd: false,
58
+ children: /* @__PURE__ */ jsx(FormatterProvider, {
59
+ isMicroFrontEnd: false,
60
+ dateFormatter: {
61
+ formatDate: format
62
+ },
63
+ currencyFormatter: {
64
+ code: domianCountry.currency,
65
+ decimalDigits: domianCountry.currency_decimal_digits
66
+ },
67
+ children
68
+ })
69
+ })]
70
+ });
71
+ }
72
+ const history = createBrowserHistory({
73
+ window
74
+ });
75
+ function MFIsolationApp(props) {
76
+ const {
77
+ children,
78
+ user,
79
+ pwd,
80
+ host_api_local,
81
+ host_api_remote,
82
+ host_static_assets,
83
+ environment_assets,
84
+ moduleId,
85
+ skeletonFlags,
86
+ moduleNameField,
87
+ privileges,
88
+ componentsDictionary,
89
+ onLoad,
90
+ activeAreasNetwork = false,
91
+ activeCookiesFromNetwork = false
92
+ } = props;
93
+ const eventEmitter = useMemo(() => new EventEmitter(), []);
94
+ const events_add_listener = useCallback((eventName, handler) => {
95
+ eventEmitter.on(eventName, handler);
96
+ }, [eventEmitter]);
97
+ const events_remove_listener = useCallback((eventName, handler) => {
98
+ if (handler === null) {
99
+ eventEmitter.removeListener(eventName);
100
+ return;
101
+ }
102
+ eventEmitter.removeListener(eventName, handler);
103
+ }, [eventEmitter]);
104
+ const events_emit = useCallback((eventName, arg) => {
105
+ eventEmitter.emit(eventName, arg);
106
+ }, [eventEmitter]);
107
+ const startProgress = () => {
108
+ NProgress.configure({
109
+ showSpinner: true
110
+ });
111
+ NProgress.start();
112
+ };
113
+ const stopProgress = () => {
114
+ NProgress.done();
115
+ };
116
+ const environment = useMemo(() => ({
117
+ host: "",
118
+ isLocalhost: true,
119
+ domain_token: "lab1",
120
+ host_api_local,
121
+ host_api_remote,
122
+ host_static_assets,
123
+ environment_assets
124
+ }), []);
125
+ const hostTools = useMemo(() => ({
126
+ history,
127
+ toast,
128
+ startProgress,
129
+ stopProgress,
130
+ events_add_listener,
131
+ events_remove_listener,
132
+ events_emit
133
+ }), []);
134
+ return /* @__PURE__ */ jsx(EnvironmentProvider, {
135
+ ...environment,
136
+ children: /* @__PURE__ */ jsx(HostToolsProvider, {
137
+ ...hostTools,
138
+ children: /* @__PURE__ */ jsx(NetworkProvider, {
139
+ axiosOperation,
140
+ children: /* @__PURE__ */ jsx(unstable_HistoryRouter, {
141
+ history,
142
+ children: /* @__PURE__ */ jsx(LocalesProvider, {
143
+ isMicroFrontEnd: false,
144
+ getLocaleFromNetwork,
145
+ children: /* @__PURE__ */ jsx(AuthProvider, {
146
+ children: /* @__PURE__ */ jsx(MFAuthApp, {
147
+ user,
148
+ pwd,
149
+ children: /* @__PURE__ */ jsx(BaseModule, {
150
+ moduleId,
151
+ privileges,
152
+ skeletonFlags,
153
+ componentsDictionary,
154
+ moduleNameField,
155
+ children: /* @__PURE__ */ jsx(AreasProvider, {
156
+ onLoad,
157
+ loadAreasFromNetwork: activeAreasNetwork,
158
+ loadCookiesFromNetwork: activeCookiesFromNetwork,
159
+ onSelectLayout: (modId) => {
160
+ console.log("onSelectLayout", modId);
161
+ },
162
+ children
163
+ })
164
+ })
165
+ })
166
+ })
167
+ })
168
+ })
169
+ })
170
+ })
171
+ });
172
+ }
173
+ export {
174
+ MFIsolationApp as M
175
+ };
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { MFAuthAppProps } from './types';
2
- export declare function MFAuthApp(props: MFAuthAppProps): JSX.Element;
3
+ export declare function MFAuthApp(props: MFAuthAppProps): import("react").JSX.Element;
3
4
  export default MFAuthApp;
@@ -1,4 +1,4 @@
1
- import "./MFIsolationApp/index.ed197bc0.js";
1
+ import "./MFIsolationApp/index.e36cf308.js";
2
2
  import "react-router-dom";
3
3
  import "@m4l/core";
4
4
  import "@m4l/graphics";
@@ -1,130 +1,160 @@
1
- import { createContext as T, useReducer as y, useEffect as d } from "react";
2
- import { useHostTools as E, useNetwork as S, useEnvironment as v, useLocalStorageWithListener as N, EmitEvents as O, getLocalStorage as w, setLocalStorage as r } from "@m4l/core";
3
- import { jsx as D } from "react/jsx-runtime";
4
- var n = /* @__PURE__ */ ((e) => (e.Initial = "INITIALIZE", e.Login = "LOGIN", e.Logout = "LOGOUT", e))(n || {});
5
- const _ = {
6
- isAuthenticated: !1,
7
- isInitialized: !1,
1
+ import { createContext, useReducer, useEffect } from "react";
2
+ import { useHostTools, useNetwork, useEnvironment, useLocalStorageWithListener, EmitEvents, getLocalStorage, setLocalStorage } from "@m4l/core";
3
+ import { jsx } from "react/jsx-runtime";
4
+ var EnumTypes = /* @__PURE__ */ ((EnumTypes2) => {
5
+ EnumTypes2["Initial"] = "INITIALIZE";
6
+ EnumTypes2["Login"] = "LOGIN";
7
+ EnumTypes2["Logout"] = "LOGOUT";
8
+ return EnumTypes2;
9
+ })(EnumTypes || {});
10
+ const initialState = {
11
+ isAuthenticated: false,
12
+ isInitialized: false,
8
13
  user: null
9
- }, P = (e, t) => {
10
- switch (t.type) {
14
+ };
15
+ const JWTReducer = (state, action) => {
16
+ switch (action.type) {
11
17
  case "INITIALIZE":
12
18
  return {
13
- isAuthenticated: t.payload.isAuthenticated,
14
- isInitialized: !0,
15
- user: t.payload.user
19
+ isAuthenticated: action.payload.isAuthenticated,
20
+ isInitialized: true,
21
+ user: action.payload.user
16
22
  };
17
23
  case "LOGIN":
18
24
  return {
19
- ...e,
20
- isAuthenticated: !0,
21
- user: t.payload.user
25
+ ...state,
26
+ isAuthenticated: true,
27
+ user: action.payload.user
22
28
  };
23
29
  case "LOGOUT":
24
30
  return {
25
- ...e,
26
- isAuthenticated: !1,
31
+ ...state,
32
+ isAuthenticated: false,
27
33
  user: null
28
34
  };
29
35
  default:
30
- return e;
36
+ return state;
31
37
  }
32
- }, x = T(null);
33
- function z(e) {
34
- e({
35
- type: n.Initial,
38
+ };
39
+ const AuthContext = createContext(null);
40
+ function dispatchInitial(dispatch) {
41
+ dispatch({
42
+ type: EnumTypes.Initial,
36
43
  payload: {
37
- isAuthenticated: !1,
44
+ isAuthenticated: false,
38
45
  user: null
39
46
  }
40
47
  });
41
48
  }
42
- function R(e) {
49
+ function AuthProvider(props) {
50
+ const {
51
+ children
52
+ } = props;
53
+ const [state, dispatch] = useReducer(JWTReducer, initialState);
54
+ const {
55
+ events_add_listener
56
+ } = useHostTools();
43
57
  const {
44
- children: t
45
- } = e, [h, s] = y(P, _), {
46
- events_add_listener: I
47
- } = E(), {
48
- networkOperation: u
49
- } = S(), {
50
- domain_token: m
51
- } = v(), [f, l] = N(
58
+ networkOperation
59
+ } = useNetwork();
60
+ const {
61
+ domain_token
62
+ } = useEnvironment();
63
+ const [nextValSession, setNextValSession] = useLocalStorageWithListener(
52
64
  "vSession",
53
65
  new Date().getTime() + ""
54
66
  );
55
- d(() => {
56
- (async () => {
57
- u({
67
+ useEffect(() => {
68
+ const initialize = async () => {
69
+ networkOperation({
58
70
  method: "GET",
59
- endPoint: "auth/login",
71
+ endPoint: `auth/login`,
60
72
  parms: {
61
- user_data: !0
73
+ user_data: true
62
74
  },
63
- checkUnAuthorized: !1
64
- }).then((a) => {
65
- s({
66
- type: n.Initial,
75
+ checkUnAuthorized: false
76
+ }).then((response) => {
77
+ dispatch({
78
+ type: EnumTypes.Initial,
67
79
  payload: {
68
- isAuthenticated: !0,
69
- user: a.user
80
+ isAuthenticated: true,
81
+ user: response.user
70
82
  }
71
- }), w("userData", {
72
- email: a.user.email,
73
- remember: !0
74
- })?.email !== a.user.email && r("userData", {
75
- email: a.user.email
76
- }, !0);
83
+ });
84
+ const useSaved = getLocalStorage("userData", {
85
+ email: response.user.email,
86
+ remember: true
87
+ });
88
+ if (useSaved?.email !== response.user.email) {
89
+ setLocalStorage("userData", {
90
+ email: response.user.email
91
+ }, true);
92
+ }
77
93
  }).catch(() => {
78
- z(s);
94
+ dispatchInitial(dispatch);
79
95
  });
80
- })();
81
- }, [f]);
82
- const g = async (i, a, o) => {
83
- await u({
84
- endPoint: "auth/login",
96
+ };
97
+ initialize();
98
+ }, [nextValSession]);
99
+ const login = async (email, password, remember) => {
100
+ await networkOperation({
101
+ endPoint: `auth/login`,
85
102
  method: "POST",
86
103
  data: {
87
- email: i,
88
- password: a,
89
- domain_token: m
104
+ email,
105
+ password,
106
+ domain_token
107
+ }
108
+ }).then((response) => {
109
+ const user = response.data;
110
+ if (remember) {
111
+ setLocalStorage("userData", {
112
+ email,
113
+ remember
114
+ });
115
+ } else {
116
+ setLocalStorage("userData", {
117
+ email: "",
118
+ remember
119
+ });
90
120
  }
91
- }).then((A) => {
92
- const L = A.data;
93
- o ? r("userData", {
94
- email: i,
95
- remember: o
96
- }) : r("userData", {
97
- email: "",
98
- remember: o
99
- }), s({
100
- type: n.Login,
121
+ dispatch({
122
+ type: EnumTypes.Login,
101
123
  payload: {
102
- user: L
124
+ user
103
125
  }
104
- }), l(new Date().getTime() + "");
126
+ });
127
+ setNextValSession(new Date().getTime() + "");
128
+ });
129
+ };
130
+ const logout = async (isAuthenticated) => {
131
+ if (isAuthenticated) {
132
+ await networkOperation({
133
+ endPoint: `auth/logout`,
134
+ method: "POST"
135
+ });
136
+ }
137
+ dispatch({
138
+ type: EnumTypes.Logout
105
139
  });
106
- }, c = async (i) => {
107
- i && await u({
108
- endPoint: "auth/logout",
109
- method: "POST"
110
- }), s({
111
- type: n.Logout
112
- }), l(new Date().getTime() + "");
113
- }, p = () => {
114
- c(!1);
140
+ setNextValSession(new Date().getTime() + "");
141
+ };
142
+ const onNetserviceUnautorized = () => {
143
+ logout(false);
115
144
  };
116
- return d(() => {
117
- I(O.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED, p);
118
- }, []), /* @__PURE__ */ D(x.Provider, {
145
+ useEffect(() => {
146
+ events_add_listener(EmitEvents.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED, onNetserviceUnautorized);
147
+ }, []);
148
+ return /* @__PURE__ */ jsx(AuthContext.Provider, {
119
149
  value: {
120
- ...h,
121
- login: g,
122
- logout: c
150
+ ...state,
151
+ login,
152
+ logout
123
153
  },
124
- children: t
154
+ children
125
155
  });
126
156
  }
127
157
  export {
128
- R as A,
129
- x as a
158
+ AuthProvider as A,
159
+ AuthContext as a
130
160
  };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import type { AuthProviderProps, SessionContextType } from './types';
3
3
  declare const AuthContext: import("react").Context<SessionContextType | null>;
4
- declare function AuthProvider(props: AuthProviderProps): JSX.Element;
4
+ declare function AuthProvider(props: AuthProviderProps): import("react").JSX.Element;
5
5
  export { AuthContext, AuthProvider };
@@ -0,0 +1,4 @@
1
+ import "react";
2
+ import "../layouts/MasterDetailLayout/index.bca0fce5.js";
3
+ import "../contexts/AuthContext/index.6f966215.js";
4
+ import "../layouts/ModuleLayout/index.850f7dcf.js";