@m4l/core 2.0.2 → 2.0.4
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.
- package/contexts/AuthContext/constants.d.ts +5 -0
- package/contexts/AuthContext/index.d.ts +1 -1
- package/contexts/AuthContext/index.dd2ed9e6.js +137 -0
- package/contexts/AuthContext/types.d.ts +17 -18
- package/contexts/BaseContext/index.d.ts +1 -0
- package/contexts/DomainContext/index.d.ts +1 -0
- package/contexts/DomainCountryContext/index.3cdf9462.js +46 -0
- package/contexts/DomainCountryContext/index.d.ts +1 -0
- package/contexts/EnvironmentContext/index.d.ts +1 -0
- package/contexts/FlagsContext/index.d.ts +1 -0
- package/contexts/HostToolsContext/index.d.ts +1 -0
- package/contexts/ModuleDictionaryContext/index.63e1dbbd.js +74 -0
- package/contexts/ModuleDictionaryContext/index.d.ts +1 -0
- package/contexts/ModulePrivilegesContext/index.1274092a.js +52 -0
- package/contexts/ModulePrivilegesContext/index.d.ts +1 -0
- package/contexts/ModuleSkeletonContext/index.9267d86a.js +20 -0
- package/contexts/ModuleSkeletonContext/index.d.ts +1 -0
- package/contexts/NetworkContext/index.d.ts +1 -0
- package/contexts/index.d.ts +1 -1
- package/hooks/useAuth/index.94b696a7.js +11 -0
- package/hooks/useAuth/useAuth.d.ts +1 -1
- package/hooks/useDomain/{index.be2722d9.js → index.dd6909f6.js} +1 -1
- package/hooks/useModuleDictionary/{index.9004a259.js → index.80b52ae5.js} +1 -1
- package/hooks/useModulePrivileges/{index.6ebd7c42.js → index.e93abed8.js} +1 -1
- package/hooks/useModuleSkeleton/{index.1cdf5081.js → index.a8238d1d.js} +1 -1
- package/hooks/usePaginate/index.0a5d70e5.js +74 -0
- package/hooks/usePaginate/index.d.ts +1 -0
- package/hooks/usePaginate/types.d.ts +2 -0
- package/index.js +66 -66
- package/package.json +1 -1
- package/types/dictionary.d.ts +1 -1
- package/types/index.d.ts +1 -0
- package/utils/getPropertyByString/index.d.ts +3 -1
- package/utils/index.54ccec2f.js +61 -0
- package/vite-env.d.ts +4 -4
- package/contexts/AuthContext/index.db46edbc.js +0 -150
- package/contexts/DomainCountryContext/index.506456a3.js +0 -57
- package/contexts/ModuleDictionaryContext/index.a64207d4.js +0 -81
- package/contexts/ModulePrivilegesContext/index.79c3cc04.js +0 -62
- package/contexts/ModuleSkeletonContext/index.f6150fb9.js +0 -30
- package/hooks/useAuth/index.4154d394.js +0 -21
- package/hooks/usePaginate/index.1306b0de.js +0 -70
- package/utils/index.2f5ce5aa.js +0 -65
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './AuthContext';
|
|
2
|
-
export
|
|
2
|
+
export type { UserAuth, AuthState } from './types';
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { createContext as A, useReducer as y, useEffect as d } from "react";
|
|
2
|
+
import { E } from "../../types/index.42c24946.js";
|
|
3
|
+
import { jsx as v } from "react/jsx-runtime";
|
|
4
|
+
import { u as D } from "../../hooks/useHostTools/index.66d9a667.js";
|
|
5
|
+
import { u as N } from "../../hooks/useNetwork/index.3d79002b.js";
|
|
6
|
+
import { u as O } from "../../hooks/useEnvironment/index.25f83176.js";
|
|
7
|
+
import { u as S } from "../../hooks/useLocalStorage/index.91bc0791.js";
|
|
8
|
+
import { g as U, s as u } from "../../utils/index.54ccec2f.js";
|
|
9
|
+
var i = /* @__PURE__ */ ((e) => (e.Initial = "INITIALIZE", e.Login = "LOGIN", e.Logout = "LOGOUT", e))(i || {});
|
|
10
|
+
const w = {
|
|
11
|
+
isAuthenticated: !1,
|
|
12
|
+
isInitialized: !1,
|
|
13
|
+
user: null
|
|
14
|
+
}, _ = (e, t) => {
|
|
15
|
+
switch (t.type) {
|
|
16
|
+
case "INITIALIZE":
|
|
17
|
+
return {
|
|
18
|
+
isAuthenticated: t.payload.isAuthenticated,
|
|
19
|
+
isInitialized: !0,
|
|
20
|
+
user: t.payload.user
|
|
21
|
+
};
|
|
22
|
+
case "LOGIN":
|
|
23
|
+
return {
|
|
24
|
+
...e,
|
|
25
|
+
isAuthenticated: !0,
|
|
26
|
+
user: t.payload.user
|
|
27
|
+
};
|
|
28
|
+
case "LOGOUT":
|
|
29
|
+
return {
|
|
30
|
+
...e,
|
|
31
|
+
isAuthenticated: !1,
|
|
32
|
+
user: null
|
|
33
|
+
};
|
|
34
|
+
default:
|
|
35
|
+
return e;
|
|
36
|
+
}
|
|
37
|
+
}, C = A(null);
|
|
38
|
+
function P(e) {
|
|
39
|
+
e({
|
|
40
|
+
type: i.Initial,
|
|
41
|
+
payload: {
|
|
42
|
+
isAuthenticated: !1,
|
|
43
|
+
user: null
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function M(e) {
|
|
48
|
+
const {
|
|
49
|
+
children: t
|
|
50
|
+
} = e, [m, o] = y(_, w), {
|
|
51
|
+
events_add_listener: h
|
|
52
|
+
} = D(), {
|
|
53
|
+
networkOperation: r
|
|
54
|
+
} = N(), {
|
|
55
|
+
domain_token: f
|
|
56
|
+
} = O(), [p, l] = S(
|
|
57
|
+
"vSession",
|
|
58
|
+
new Date().getTime() + ""
|
|
59
|
+
);
|
|
60
|
+
d(() => {
|
|
61
|
+
(async () => {
|
|
62
|
+
r({
|
|
63
|
+
method: "GET",
|
|
64
|
+
endPoint: "auth/login",
|
|
65
|
+
parms: {
|
|
66
|
+
user_data: !0
|
|
67
|
+
},
|
|
68
|
+
checkUnAuthorized: !1,
|
|
69
|
+
responseToCamelCase: !0
|
|
70
|
+
}).then((s) => {
|
|
71
|
+
o({
|
|
72
|
+
type: i.Initial,
|
|
73
|
+
payload: {
|
|
74
|
+
isAuthenticated: !0,
|
|
75
|
+
user: s.user
|
|
76
|
+
}
|
|
77
|
+
}), U("userData", {
|
|
78
|
+
email: s.user.email,
|
|
79
|
+
remember: !0
|
|
80
|
+
})?.email !== s.user.email && u("userData", {
|
|
81
|
+
email: s.user.email
|
|
82
|
+
}, !0);
|
|
83
|
+
}).catch(() => {
|
|
84
|
+
P(o);
|
|
85
|
+
});
|
|
86
|
+
})();
|
|
87
|
+
}, [p]);
|
|
88
|
+
const I = async (a, s, n) => {
|
|
89
|
+
await r({
|
|
90
|
+
endPoint: "auth/login",
|
|
91
|
+
method: "POST",
|
|
92
|
+
data: {
|
|
93
|
+
email: a,
|
|
94
|
+
password: s,
|
|
95
|
+
domain_token: f
|
|
96
|
+
},
|
|
97
|
+
responseToCamelCase: !0
|
|
98
|
+
}).then((T) => {
|
|
99
|
+
const L = T.data;
|
|
100
|
+
n ? u("userData", {
|
|
101
|
+
email: a,
|
|
102
|
+
remember: n
|
|
103
|
+
}) : u("userData", {
|
|
104
|
+
email: "",
|
|
105
|
+
remember: n
|
|
106
|
+
}), o({
|
|
107
|
+
type: i.Login,
|
|
108
|
+
payload: {
|
|
109
|
+
user: L
|
|
110
|
+
}
|
|
111
|
+
}), l(new Date().getTime() + "");
|
|
112
|
+
});
|
|
113
|
+
}, c = async (a) => {
|
|
114
|
+
a && await r({
|
|
115
|
+
endPoint: "auth/logout",
|
|
116
|
+
method: "POST"
|
|
117
|
+
}), o({
|
|
118
|
+
type: i.Logout
|
|
119
|
+
}), l(new Date().getTime() + "");
|
|
120
|
+
}, g = () => {
|
|
121
|
+
c(!1);
|
|
122
|
+
};
|
|
123
|
+
return d(function() {
|
|
124
|
+
h(E.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED, g);
|
|
125
|
+
}, []), /* @__PURE__ */ v(C.Provider, {
|
|
126
|
+
value: {
|
|
127
|
+
...m,
|
|
128
|
+
login: I,
|
|
129
|
+
logout: c
|
|
130
|
+
},
|
|
131
|
+
children: t
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
export {
|
|
135
|
+
C as A,
|
|
136
|
+
M as a
|
|
137
|
+
};
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { DomainCountry } from '../DomainCountryContext/types';
|
|
3
3
|
import type { Maybe } from '../../types';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import { EnumTypes } from './constants';
|
|
5
|
+
export interface UserAuth {
|
|
6
|
+
email: string;
|
|
7
|
+
id: number;
|
|
8
|
+
firstName: string;
|
|
9
|
+
lastName: string;
|
|
10
|
+
accountId: number;
|
|
11
|
+
domainCountry: DomainCountry;
|
|
12
|
+
avatarUrl?: Maybe<string>;
|
|
13
|
+
userTypeId?: number;
|
|
14
|
+
preferences?: {
|
|
15
|
+
deviceLabel?: string;
|
|
16
|
+
};
|
|
8
17
|
}
|
|
18
|
+
export declare type AuthUserType = Maybe<UserAuth>;
|
|
9
19
|
export declare type AuthProviderProps = {
|
|
10
20
|
children: ReactNode;
|
|
11
21
|
};
|
|
@@ -22,29 +32,18 @@ export declare type ActionMap<M extends {
|
|
|
22
32
|
export declare type SessionAuthPayload = {
|
|
23
33
|
[EnumTypes.Initial]: {
|
|
24
34
|
isAuthenticated: boolean;
|
|
25
|
-
user:
|
|
35
|
+
user: AuthUserType;
|
|
26
36
|
};
|
|
27
37
|
[EnumTypes.Login]: {
|
|
28
|
-
user:
|
|
38
|
+
user: AuthUserType;
|
|
29
39
|
};
|
|
30
40
|
[EnumTypes.Logout]: undefined;
|
|
31
41
|
};
|
|
32
42
|
export declare type SessionActions = ActionMap<SessionAuthPayload>[keyof ActionMap<SessionAuthPayload>];
|
|
33
|
-
export interface User {
|
|
34
|
-
email: string;
|
|
35
|
-
id: number;
|
|
36
|
-
first_name: string;
|
|
37
|
-
last_name: string;
|
|
38
|
-
account_id: number;
|
|
39
|
-
domain_country: DomainCountry;
|
|
40
|
-
avatar_url?: Maybe<string>;
|
|
41
|
-
user_type_id?: number;
|
|
42
|
-
}
|
|
43
|
-
export declare type AuthUser = Maybe<User>;
|
|
44
43
|
export declare type AuthState = {
|
|
45
44
|
isAuthenticated: boolean;
|
|
46
45
|
isInitialized: boolean;
|
|
47
|
-
user:
|
|
46
|
+
user: Maybe<UserAuth>;
|
|
48
47
|
};
|
|
49
48
|
export interface SessionContextType extends AuthState {
|
|
50
49
|
login: (email: string, password: string, remember: boolean) => object | undefined;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createContext as d, useState as y, useCallback as T } from "react";
|
|
2
|
+
import { E as r } from "../../types/index.42c24946.js";
|
|
3
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
4
|
+
import { u as D } from "../../hooks/useHostTools/index.66d9a667.js";
|
|
5
|
+
import { u as M } from "../../hooks/usePropageteMF/index.c440b829.js";
|
|
6
|
+
const N = d(null);
|
|
7
|
+
function A(e) {
|
|
8
|
+
const {
|
|
9
|
+
children: s,
|
|
10
|
+
isMicroFrontEnd: t,
|
|
11
|
+
id: i,
|
|
12
|
+
currency: a,
|
|
13
|
+
currency_decimal_digits: m,
|
|
14
|
+
decimal_symbol: c,
|
|
15
|
+
thousands_symbol: u
|
|
16
|
+
} = e, {
|
|
17
|
+
events_emit: _
|
|
18
|
+
} = D(), [l, C] = y({
|
|
19
|
+
id: i,
|
|
20
|
+
currency: a,
|
|
21
|
+
currency_decimal_digits: m,
|
|
22
|
+
decimal_symbol: c,
|
|
23
|
+
thousands_symbol: u
|
|
24
|
+
}), n = (o) => {
|
|
25
|
+
C(o);
|
|
26
|
+
};
|
|
27
|
+
M({
|
|
28
|
+
isMicroFrontEnd: t,
|
|
29
|
+
event: r.EMMIT_EVENT_HOST_DOMAIN_COUNTRY_CHANGE,
|
|
30
|
+
setHandler: n
|
|
31
|
+
});
|
|
32
|
+
const E = T((o) => {
|
|
33
|
+
t || (n(o), _(r.EMMIT_EVENT_HOST_DOMAIN_COUNTRY_CHANGE, o));
|
|
34
|
+
}, []);
|
|
35
|
+
return /* @__PURE__ */ f(N.Provider, {
|
|
36
|
+
value: {
|
|
37
|
+
...l,
|
|
38
|
+
changeDomainCountry: E
|
|
39
|
+
},
|
|
40
|
+
children: s
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
N as D,
|
|
45
|
+
A as a
|
|
46
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { DomainCountryContextType, DomainCountryProviderProps } from './types';
|
|
2
3
|
declare const DomainCountryContext: import("react").Context<DomainCountryContextType | null>;
|
|
3
4
|
declare function DomainCountryProvider(props: DomainCountryProviderProps): import("react").JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { EnvironmentContextType, EnvironmentProviderProps } from './types';
|
|
2
3
|
declare const EnvironmentContext: import("react").Context<EnvironmentContextType | null>;
|
|
3
4
|
declare function EnvironmentProvider(props: EnvironmentProviderProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { createContext as y, useState as L, useEffect as M, useCallback as c } from "react";
|
|
2
|
+
import { C as N } from "../../types/index.42c24946.js";
|
|
3
|
+
import { jsx as P } from "react/jsx-runtime";
|
|
4
|
+
import { u as _ } from "../../hooks/useFlagsStore/index.f7c613ac.js";
|
|
5
|
+
import { u as $ } from "../../hooks/useEnvironment/index.25f83176.js";
|
|
6
|
+
import { u as x } from "../../hooks/useHostTools/index.66d9a667.js";
|
|
7
|
+
import { u as E } from "../../hooks/useNetwork/index.3d79002b.js";
|
|
8
|
+
const b = y(null);
|
|
9
|
+
function j(m) {
|
|
10
|
+
const {
|
|
11
|
+
children: d,
|
|
12
|
+
componentsDictionary: f,
|
|
13
|
+
moduleId: a,
|
|
14
|
+
moduleNameField: l = "module_name",
|
|
15
|
+
currentLang: p = "en",
|
|
16
|
+
isAuth: u = !0
|
|
17
|
+
} = m, g = _((t) => t.flagsActions.addFlag), [r, h] = L(void 0), {
|
|
18
|
+
domain_token: D
|
|
19
|
+
} = $(), {
|
|
20
|
+
startProgress: v,
|
|
21
|
+
stopProgress: A
|
|
22
|
+
} = x(), {
|
|
23
|
+
networkOperation: C
|
|
24
|
+
} = E();
|
|
25
|
+
M(() => {
|
|
26
|
+
let t = !0;
|
|
27
|
+
return v(), C({
|
|
28
|
+
method: "GET",
|
|
29
|
+
endPoint: u ? `dictionaries/${a}` : `na/dictionaries/${a}`,
|
|
30
|
+
parms: {
|
|
31
|
+
comps: f,
|
|
32
|
+
...u ? {} : {
|
|
33
|
+
domain_token: D
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}).then((e) => {
|
|
37
|
+
t && (h({
|
|
38
|
+
...e
|
|
39
|
+
}), g(N.FLAG_DICTIONARY_LOADED));
|
|
40
|
+
}).finally(() => {
|
|
41
|
+
A();
|
|
42
|
+
}), function() {
|
|
43
|
+
t = !1;
|
|
44
|
+
};
|
|
45
|
+
}, [p]);
|
|
46
|
+
const s = c((t, ...e) => {
|
|
47
|
+
if (r === void 0)
|
|
48
|
+
return "";
|
|
49
|
+
if (t === "")
|
|
50
|
+
return "No key";
|
|
51
|
+
let o;
|
|
52
|
+
const i = t.split(".");
|
|
53
|
+
try {
|
|
54
|
+
i.length === 1 && (o = r.data[t]), i.length === 2 && (o = r[i[0]][i[1]]);
|
|
55
|
+
} catch {
|
|
56
|
+
}
|
|
57
|
+
if (e.length > 0 && o)
|
|
58
|
+
for (let n = 0; n < e.length; n++)
|
|
59
|
+
o = o?.replaceAll(`$${n + 1}`, e[n]);
|
|
60
|
+
return o || `N_D:[${t}]`;
|
|
61
|
+
}, [r]), F = c(() => s(l), [l, s]);
|
|
62
|
+
return /* @__PURE__ */ P(b.Provider, {
|
|
63
|
+
value: {
|
|
64
|
+
moduleDictionary: r,
|
|
65
|
+
getLabel: s,
|
|
66
|
+
getModuleLabel: F
|
|
67
|
+
},
|
|
68
|
+
children: d
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
b as M,
|
|
73
|
+
j as a
|
|
74
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { ModuleDictionaryContextProps, ModuleDictionaryProviderProps } from './types';
|
|
2
3
|
declare const ModuleDictionaryContext: import("react").Context<ModuleDictionaryContextProps | null>;
|
|
3
4
|
declare function ModuleDictionaryProvider(props: ModuleDictionaryProviderProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createContext as f, useState as d, useEffect as p, useCallback as P } from "react";
|
|
2
|
+
import { C as i } from "../../types/index.42c24946.js";
|
|
3
|
+
import { jsx as v } from "react/jsx-runtime";
|
|
4
|
+
import { u as E } from "../../hooks/useFlagsStore/index.f7c613ac.js";
|
|
5
|
+
import { u as h } from "../../hooks/useHostTools/index.66d9a667.js";
|
|
6
|
+
import { u as F } from "../../hooks/useNetwork/index.3d79002b.js";
|
|
7
|
+
const L = f(null);
|
|
8
|
+
function S(n) {
|
|
9
|
+
const {
|
|
10
|
+
children: a,
|
|
11
|
+
queryPrivileges: r
|
|
12
|
+
} = n, o = E((e) => e.flagsActions.addFlag), [t, l] = d({}), {
|
|
13
|
+
startProgress: u,
|
|
14
|
+
stopProgress: m
|
|
15
|
+
} = h(), {
|
|
16
|
+
networkOperation: g
|
|
17
|
+
} = F();
|
|
18
|
+
p(() => {
|
|
19
|
+
let e = !0;
|
|
20
|
+
if (r.length === 0) {
|
|
21
|
+
o(i.FLAG_PRIVILEGES_LOADED);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
return u(), g({
|
|
25
|
+
method: "GET",
|
|
26
|
+
endPoint: "auth/login",
|
|
27
|
+
parms: {
|
|
28
|
+
privileges: r
|
|
29
|
+
}
|
|
30
|
+
}).then((s) => {
|
|
31
|
+
e && (l({
|
|
32
|
+
...s.data
|
|
33
|
+
}), o(i.FLAG_PRIVILEGES_LOADED));
|
|
34
|
+
}).finally(() => {
|
|
35
|
+
m();
|
|
36
|
+
}), function() {
|
|
37
|
+
e = !1;
|
|
38
|
+
};
|
|
39
|
+
}, []);
|
|
40
|
+
const c = P((e) => e in t, [t]);
|
|
41
|
+
return /* @__PURE__ */ v(L.Provider, {
|
|
42
|
+
value: {
|
|
43
|
+
hasPrivilege: c,
|
|
44
|
+
privileges: t
|
|
45
|
+
},
|
|
46
|
+
children: a
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
L as M,
|
|
51
|
+
S as a
|
|
52
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { ModulePrivilegesContextProps, ModulePrivilegesProviderProps } from './types';
|
|
2
3
|
declare const ModulePrivilegesContext: import("react").Context<ModulePrivilegesContextProps | null>;
|
|
3
4
|
declare function ModulePrivilegesProvider(props: ModulePrivilegesProviderProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createContext as n } from "react";
|
|
2
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
3
|
+
import { a as l } from "../../hooks/useFlagsStore/index.f7c613ac.js";
|
|
4
|
+
const a = n(null);
|
|
5
|
+
function m(e) {
|
|
6
|
+
const {
|
|
7
|
+
children: o,
|
|
8
|
+
flags: t
|
|
9
|
+
} = e, r = !l(t);
|
|
10
|
+
return /* @__PURE__ */ s(a.Provider, {
|
|
11
|
+
value: {
|
|
12
|
+
isSkeleton: r
|
|
13
|
+
},
|
|
14
|
+
children: o
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
a as M,
|
|
19
|
+
m as a
|
|
20
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { ModuleSkeletonContextProps, ModuleSkeletonProviderProps } from './types';
|
|
2
3
|
declare const ModuleSkeletonContext: import("react").Context<ModuleSkeletonContextProps | null>;
|
|
3
4
|
declare function ModuleSkeletonProvider(props: ModuleSkeletonProviderProps): import("react").JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import type { NetworkProviderProps } from './types';
|
|
2
3
|
declare const NetworkContext: import("react").Context<import("./types").NetworkType | null>;
|
|
3
4
|
declare function NetworkProvider(props: NetworkProviderProps): import("react").JSX.Element;
|
package/contexts/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { BaseContext, BaseProvider } from './BaseContext';
|
|
|
2
2
|
export { EnvironmentContext, EnvironmentProvider } from './EnvironmentContext';
|
|
3
3
|
export { HostToolsContext, HostToolsProvider } from './HostToolsContext';
|
|
4
4
|
export { NetworkContext, NetworkProvider } from './NetworkContext';
|
|
5
|
-
export
|
|
5
|
+
export * from './AuthContext';
|
|
6
6
|
export { FlagsContext, FlagsProvider } from './FlagsContext';
|
|
7
7
|
export { DomainContext, DomainProvider } from './DomainContext';
|
|
8
8
|
export { ModuleDictionaryContext, ModuleDictionaryProvider } from './ModuleDictionaryContext';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useContext as o } from "react";
|
|
2
|
+
import { A as e } from "../../contexts/AuthContext/index.dd2ed9e6.js";
|
|
3
|
+
const n = () => {
|
|
4
|
+
const t = o(e);
|
|
5
|
+
if (!t)
|
|
6
|
+
throw new Error("Auth context must be use inside AuthProvider");
|
|
7
|
+
return t;
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
n as u
|
|
11
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const useAuth: () => import("../../contexts/AuthContext").SessionContextType;
|
|
1
|
+
export declare const useAuth: () => import("../../contexts/AuthContext/types").SessionContextType;
|
|
2
2
|
export default useAuth;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContext as t } from "react";
|
|
2
2
|
import { D as n } from "../../contexts/DomainContext/index.2ed56159.js";
|
|
3
|
-
import { D as e } from "../../contexts/DomainCountryContext/index.
|
|
3
|
+
import { D as e } from "../../contexts/DomainCountryContext/index.3cdf9462.js";
|
|
4
4
|
const m = () => {
|
|
5
5
|
const o = t(n);
|
|
6
6
|
if (!o)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState as n, useContext as s, useEffect as u } from "react";
|
|
2
|
-
import { M as r } from "../../contexts/ModuleSkeletonContext/index.
|
|
2
|
+
import { M as r } from "../../contexts/ModuleSkeletonContext/index.9267d86a.js";
|
|
3
3
|
const S = () => {
|
|
4
4
|
const [t, o] = n(!0), e = s(r);
|
|
5
5
|
if (!e)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { useState as n, useRef as H, useCallback as L, useEffect as m } from "react";
|
|
2
|
+
import { u as U } from "../useHostTools/index.66d9a667.js";
|
|
3
|
+
import { u as j } from "../useNetwork/index.3d79002b.js";
|
|
4
|
+
const s = {
|
|
5
|
+
page: 0,
|
|
6
|
+
rowsPerPage: 25,
|
|
7
|
+
totalRecords: 0
|
|
8
|
+
}, J = (w) => {
|
|
9
|
+
const {
|
|
10
|
+
endPoint: h,
|
|
11
|
+
timeout: R = 5e3,
|
|
12
|
+
queryParams: P,
|
|
13
|
+
fireOnChangeParms: i,
|
|
14
|
+
fireOnFirstLoad: C = !0,
|
|
15
|
+
rowsPerPage: c = s.rowsPerPage,
|
|
16
|
+
startProgress: d,
|
|
17
|
+
stopProgress: S,
|
|
18
|
+
isRemote: k = !0,
|
|
19
|
+
bodyToSnakeCase: y = !1,
|
|
20
|
+
responseToCamelCase: T = !1,
|
|
21
|
+
initialRows: E = [],
|
|
22
|
+
externalCondition: u = !0,
|
|
23
|
+
onNetworkError: f
|
|
24
|
+
} = w, [p, g] = n(i ? 1 : 0), [O, o] = n(E), [b, a] = n({ ...s, rowsPerPage: c }), t = H({ ...s, rowsPerPage: c }), [x, F] = n(C), { startProgress: N, stopProgress: Q } = U(), { networkOperation: q } = j(), l = L(() => {
|
|
25
|
+
g((r) => r + 1);
|
|
26
|
+
}, []);
|
|
27
|
+
return m(() => {
|
|
28
|
+
if (x) {
|
|
29
|
+
F(!1);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
i && l();
|
|
33
|
+
}, [P]), m(() => {
|
|
34
|
+
let r = !0;
|
|
35
|
+
if (!(!u || p === 0))
|
|
36
|
+
return q({
|
|
37
|
+
method: "GET",
|
|
38
|
+
endPoint: h,
|
|
39
|
+
timeout: R,
|
|
40
|
+
parms: {
|
|
41
|
+
...P,
|
|
42
|
+
page: t.current.page,
|
|
43
|
+
limit: t.current.rowsPerPage
|
|
44
|
+
},
|
|
45
|
+
bodyToSnakeCase: y,
|
|
46
|
+
responseToCamelCase: T,
|
|
47
|
+
options: {
|
|
48
|
+
startProgress: d || N,
|
|
49
|
+
stopProgress: S || Q
|
|
50
|
+
},
|
|
51
|
+
isRemote: k
|
|
52
|
+
}).then((e) => {
|
|
53
|
+
r && (o(e.data), t.current.page = e.pager.page, a((G) => ({
|
|
54
|
+
...G,
|
|
55
|
+
page: e.pager.page,
|
|
56
|
+
totalRecords: e.pager.total
|
|
57
|
+
})));
|
|
58
|
+
}).catch(() => {
|
|
59
|
+
o([]), a(s), f && f();
|
|
60
|
+
}), function() {
|
|
61
|
+
r = !1;
|
|
62
|
+
};
|
|
63
|
+
}, [p, u]), { onPageChange: (r) => {
|
|
64
|
+
t.current.page = r, g((e) => e + 1);
|
|
65
|
+
}, onRowsPerPageChange: (r) => {
|
|
66
|
+
t.current.rowsPerPage = r, a((e) => ({ ...e, rowsPerPage: r })), g((e) => e + 1);
|
|
67
|
+
}, pagerState: b, rows: O, clearRows: () => {
|
|
68
|
+
o([]), a(s);
|
|
69
|
+
}, Refresh: l, setRows: o };
|
|
70
|
+
};
|
|
71
|
+
export {
|
|
72
|
+
s as i,
|
|
73
|
+
J as u
|
|
74
|
+
};
|