@m4l/layouts 0.1.25 → 0.1.28
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/package.json +8 -52
- package/.eslintignore +0 -2
- package/.eslintrc.cjs +0 -118
- package/.gitignore +0 -23
- package/.gitlab-ci.yml +0 -16
- package/.prettierignore +0 -3
- package/.prettierrc.json +0 -26
- package/.vscode/settings.json +0 -50
- package/dist/package.json +0 -36
- package/src/@types/index.ts +0 -8
- package/src/components/BaseModule/index.tsx +0 -59
- package/src/components/BaseModule/types.ts +0 -12
- package/src/components/MFHostApp/index.tsx +0 -95
- package/src/components/MFHostApp/types.ts +0 -16
- package/src/components/MFIsolationApp/index.tsx +0 -164
- package/src/components/MFIsolationApp/subcomponents/MFAuthApp/index.tsx +0 -98
- package/src/components/MFIsolationApp/subcomponents/MFAuthApp/types.ts +0 -7
- package/src/components/MFIsolationApp/types.ts +0 -12
- package/src/components/index.ts +0 -5
- package/src/contexts/AuthContext/index.tsx +0 -189
- package/src/contexts/AuthContext/types.ts +0 -65
- package/src/contexts/index.ts +0 -1
- package/src/hooks/index.ts +0 -5
- package/src/hooks/useAuth/index.ts +0 -12
- package/src/hooks/useMasterDetail/index.ts +0 -6
- package/src/hooks/useModule/index.ts +0 -13
- package/src/index.ts +0 -7
- package/src/layouts/MasterDetailLayout/components/ButtonDetail/index.tsx +0 -38
- package/src/layouts/MasterDetailLayout/contexts/MasterDetailContext/index.tsx +0 -34
- package/src/layouts/MasterDetailLayout/contexts/MasterDetailContext/types.ts +0 -19
- package/src/layouts/MasterDetailLayout/dicctionary.ts +0 -20
- package/src/layouts/MasterDetailLayout/index.tsx +0 -165
- package/src/layouts/MasterDetailLayout/types.ts +0 -11
- package/src/layouts/ModuleLayout/contexts/ModuleContext/index.tsx +0 -56
- package/src/layouts/ModuleLayout/contexts/ModuleContext/types.ts +0 -23
- package/src/layouts/ModuleLayout/dicctionary.ts +0 -11
- package/src/layouts/ModuleLayout/index.tsx +0 -59
- package/src/layouts/ModuleLayout/subcomponents/InnerModule/index.tsx +0 -35
- package/src/layouts/ModuleLayout/subcomponents/InnerModule/styles.tsx +0 -31
- package/src/layouts/ModuleLayout/subcomponents/InnerModule/types.ts +0 -11
- package/src/layouts/ModuleLayout/types.ts +0 -31
- package/src/layouts/NoAuthModuleLayout/dicctionary.ts +0 -9
- package/src/layouts/NoAuthModuleLayout/index.tsx +0 -85
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/index.tsx +0 -43
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/styles.tsx +0 -6
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/index.tsx +0 -14
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/styles.tsx +0 -7
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/AppBar/index.tsx +0 -25
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/AppBar/styles.tsx +0 -11
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/index.tsx +0 -17
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/styles.tsx +0 -19
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/subcomponents/NameDescription/index.tsx +0 -25
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/subcomponents/NameDescription/styles.tsx +0 -8
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/types.ts +0 -5
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/types.ts +0 -5
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/LogoLeyend/index.tsx +0 -28
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/LogoLeyend/styles.tsx +0 -16
- package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/types.ts +0 -5
- package/src/layouts/NoAuthModuleLayout/types.ts +0 -22
- package/src/layouts/index.ts +0 -8
- package/src/test/setup.ts +0 -1
- package/src/test/utils.tsx +0 -20
- package/src/vite-env.d.ts +0 -3
- package/tsconfig.json +0 -29
- package/tsconfig.node.json +0 -8
- package/vite.config.ts +0 -172
- /package/{dist/components → components}/BaseModule/index.6309486a.js +0 -0
- /package/{dist/components → components}/BaseModule/index.d.ts +0 -0
- /package/{dist/components → components}/BaseModule/types.d.ts +0 -0
- /package/{dist/components → components}/MFHostApp/index.1700d13a.js +0 -0
- /package/{dist/components → components}/MFHostApp/index.d.ts +0 -0
- /package/{dist/components → components}/MFHostApp/types.d.ts +0 -0
- /package/{dist/components → components}/MFIsolationApp/index.b21e5671.js +0 -0
- /package/{dist/components → components}/MFIsolationApp/index.d.ts +0 -0
- /package/{dist/components → components}/MFIsolationApp/subcomponents/MFAuthApp/index.d.ts +0 -0
- /package/{dist/components → components}/MFIsolationApp/subcomponents/MFAuthApp/types.d.ts +0 -0
- /package/{dist/components → components}/MFIsolationApp/types.d.ts +0 -0
- /package/{dist/components → components}/index.d.ts +0 -0
- /package/{dist/components → components}/index.deb4e7ac.js +0 -0
- /package/{dist/contexts → contexts}/AuthContext/index.6f966215.js +0 -0
- /package/{dist/contexts → contexts}/AuthContext/index.d.ts +0 -0
- /package/{dist/contexts → contexts}/AuthContext/types.d.ts +0 -0
- /package/{dist/contexts → contexts}/index.b46a2699.js +0 -0
- /package/{dist/contexts → contexts}/index.d.ts +0 -0
- /package/{dist/hooks → hooks}/index.2022a179.js +0 -0
- /package/{dist/hooks → hooks}/index.d.ts +0 -0
- /package/{dist/hooks → hooks}/useAuth/index.cb6a3420.js +0 -0
- /package/{dist/hooks → hooks}/useAuth/index.d.ts +0 -0
- /package/{dist/hooks → hooks}/useMasterDetail/index.1b024fd5.js +0 -0
- /package/{dist/hooks → hooks}/useMasterDetail/index.d.ts +0 -0
- /package/{dist/hooks → hooks}/useModule/index.6ff7d08a.js +0 -0
- /package/{dist/hooks → hooks}/useModule/index.d.ts +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/index.js → index.js} +0 -0
- /package/{dist/layouts → layouts}/MasterDetailLayout/contexts/MasterDetailContext/index.d.ts +0 -0
- /package/{dist/layouts → layouts}/MasterDetailLayout/contexts/MasterDetailContext/types.d.ts +0 -0
- /package/{dist/layouts → layouts}/MasterDetailLayout/dicctionary.d.ts +0 -0
- /package/{dist/layouts → layouts}/MasterDetailLayout/index.3da0ffda.js +0 -0
- /package/{dist/layouts → layouts}/MasterDetailLayout/index.d.ts +0 -0
- /package/{dist/layouts → layouts}/MasterDetailLayout/types.d.ts +0 -0
- /package/{dist/layouts → layouts}/ModuleLayout/contexts/ModuleContext/index.d.ts +0 -0
- /package/{dist/layouts → layouts}/ModuleLayout/contexts/ModuleContext/types.d.ts +0 -0
- /package/{dist/layouts → layouts}/ModuleLayout/dicctionary.d.ts +0 -0
- /package/{dist/layouts → layouts}/ModuleLayout/index.a76397df.js +0 -0
- /package/{dist/layouts → layouts}/ModuleLayout/index.d.ts +0 -0
- /package/{dist/layouts → layouts}/ModuleLayout/subcomponents/InnerModule/index.d.ts +0 -0
- /package/{dist/layouts → layouts}/ModuleLayout/subcomponents/InnerModule/styles.d.ts +0 -0
- /package/{dist/layouts → layouts}/ModuleLayout/subcomponents/InnerModule/types.d.ts +0 -0
- /package/{dist/layouts → layouts}/ModuleLayout/types.d.ts +0 -0
- /package/{dist/layouts → layouts}/NoAuthModuleLayout/dicctionary.d.ts +0 -0
- /package/{dist/layouts → layouts}/NoAuthModuleLayout/index.5d1098ef.js +0 -0
- /package/{dist/layouts → layouts}/NoAuthModuleLayout/index.d.ts +0 -0
- /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/index.d.ts +0 -0
- /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/styles.d.ts +0 -0
- /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/index.d.ts +0 -0
- /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/styles.d.ts +0 -0
- /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/AppBar/index.d.ts +0 -0
- /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/AppBar/styles.d.ts +0 -0
- /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/index.d.ts +0 -0
- /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/styles.d.ts +0 -0
- /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/subcomponents/NameDescription/index.d.ts +0 -0
- /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/subcomponents/NameDescription/styles.d.ts +0 -0
- /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/types.d.ts +0 -0
- /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/types.d.ts +0 -0
- /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/LogoLeyend/index.d.ts +0 -0
- /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/LogoLeyend/styles.d.ts +0 -0
- /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/types.d.ts +0 -0
- /package/{dist/layouts → layouts}/NoAuthModuleLayout/types.d.ts +0 -0
- /package/{dist/layouts → layouts}/index.014e41ba.js +0 -0
- /package/{dist/layouts → layouts}/index.d.ts +0 -0
- /package/{dist/vite-env.d.ts → vite-env.d.ts} +0 -0
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
// react
|
|
2
|
-
import { useCallback, useEffect, useMemo } from 'react';
|
|
3
|
-
import { unstable_HistoryRouter as HistoryRouter } from 'react-router-dom';
|
|
4
|
-
|
|
5
|
-
import { toast } from 'react-toastify';
|
|
6
|
-
|
|
7
|
-
//m4l
|
|
8
|
-
import { getLocaleFromNetwork, LocalesProvider } from '@m4l/graphics';
|
|
9
|
-
import { AuthProvider } from '../../contexts/AuthContext';
|
|
10
|
-
import {
|
|
11
|
-
axiosOperation,
|
|
12
|
-
EnvironmentProvider,
|
|
13
|
-
EnvironmentType,
|
|
14
|
-
EventListenerBase,
|
|
15
|
-
HostToolsProvider,
|
|
16
|
-
HostToolsType,
|
|
17
|
-
Maybe,
|
|
18
|
-
NetworkProvider,
|
|
19
|
-
} from '@m4l/core';
|
|
20
|
-
// external components
|
|
21
|
-
import { createBrowserHistory } from 'history';
|
|
22
|
-
import EventEmitter from 'eventemitter3';
|
|
23
|
-
// mui
|
|
24
|
-
// internal components
|
|
25
|
-
// hooks /providers
|
|
26
|
-
|
|
27
|
-
// sub comoponents
|
|
28
|
-
import MFAuthApp from './subcomponents/MFAuthApp';
|
|
29
|
-
// types
|
|
30
|
-
import { MFIsolationAppProps } from './types';
|
|
31
|
-
// network
|
|
32
|
-
|
|
33
|
-
// config
|
|
34
|
-
|
|
35
|
-
// utils
|
|
36
|
-
|
|
37
|
-
// css
|
|
38
|
-
import NProgress from 'nprogress';
|
|
39
|
-
import BaseModule from '../BaseModule';
|
|
40
|
-
import { AreasProvider } from '@m4l/components';
|
|
41
|
-
|
|
42
|
-
const history = createBrowserHistory({ window });
|
|
43
|
-
|
|
44
|
-
export function MFIsolationApp(props: MFIsolationAppProps) {
|
|
45
|
-
const {
|
|
46
|
-
children,
|
|
47
|
-
user,
|
|
48
|
-
pwd,
|
|
49
|
-
host_api_local,
|
|
50
|
-
host_api_remote,
|
|
51
|
-
host_static_assets,
|
|
52
|
-
environment_assets,
|
|
53
|
-
moduleId,
|
|
54
|
-
skeletonFlags,
|
|
55
|
-
moduleNameField,
|
|
56
|
-
privileges,
|
|
57
|
-
componentsDictionary,
|
|
58
|
-
onLoad,
|
|
59
|
-
activeAreasNetwork = false,
|
|
60
|
-
} = props;
|
|
61
|
-
|
|
62
|
-
const eventEmitter = useMemo(() => new EventEmitter(), []);
|
|
63
|
-
|
|
64
|
-
const events_add_listener = useCallback(
|
|
65
|
-
(eventName: string, handler: EventListenerBase) => {
|
|
66
|
-
eventEmitter.on(eventName, handler);
|
|
67
|
-
},
|
|
68
|
-
[eventEmitter],
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
const events_remove_listener = useCallback(
|
|
72
|
-
(eventName: string, handler: Maybe<EventListenerBase>) => {
|
|
73
|
-
if (handler === null) {
|
|
74
|
-
eventEmitter.removeListener(eventName);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
eventEmitter.removeListener(eventName, handler);
|
|
78
|
-
},
|
|
79
|
-
[eventEmitter],
|
|
80
|
-
);
|
|
81
|
-
const events_emit = useCallback(
|
|
82
|
-
(eventName: string, arg: any) => {
|
|
83
|
-
eventEmitter.emit(eventName, arg);
|
|
84
|
-
},
|
|
85
|
-
[eventEmitter],
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
const startProgress = () => {
|
|
89
|
-
NProgress.configure({
|
|
90
|
-
showSpinner: true,
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
NProgress.start();
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const stopProgress = () => {
|
|
97
|
-
NProgress.done();
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const environment: EnvironmentType = useMemo(
|
|
101
|
-
() => ({
|
|
102
|
-
host: '',
|
|
103
|
-
isLocalhost: true,
|
|
104
|
-
domain_token: 'lab1',
|
|
105
|
-
host_api_local,
|
|
106
|
-
host_api_remote,
|
|
107
|
-
host_static_assets,
|
|
108
|
-
environment_assets,
|
|
109
|
-
}),
|
|
110
|
-
[],
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
const hostTools: HostToolsType = useMemo(
|
|
114
|
-
() => ({
|
|
115
|
-
history,
|
|
116
|
-
toast,
|
|
117
|
-
startProgress,
|
|
118
|
-
stopProgress,
|
|
119
|
-
events_add_listener,
|
|
120
|
-
events_remove_listener,
|
|
121
|
-
events_emit,
|
|
122
|
-
}),
|
|
123
|
-
[],
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
useEffect(() => {
|
|
127
|
-
console.log('useEffect IsolationApp');
|
|
128
|
-
}, []);
|
|
129
|
-
return (
|
|
130
|
-
<EnvironmentProvider {...environment}>
|
|
131
|
-
<HostToolsProvider {...hostTools}>
|
|
132
|
-
<NetworkProvider axiosOperation={axiosOperation}>
|
|
133
|
-
<HistoryRouter history={history}>
|
|
134
|
-
<LocalesProvider
|
|
135
|
-
isMicroFrontEnd={false}
|
|
136
|
-
getLocaleFromNetwork={getLocaleFromNetwork}
|
|
137
|
-
>
|
|
138
|
-
<AuthProvider>
|
|
139
|
-
<MFAuthApp user={user} pwd={pwd}>
|
|
140
|
-
<BaseModule
|
|
141
|
-
moduleId={moduleId}
|
|
142
|
-
privileges={privileges}
|
|
143
|
-
skeletonFlags={skeletonFlags}
|
|
144
|
-
componentsDictionary={componentsDictionary}
|
|
145
|
-
moduleNameField={moduleNameField}
|
|
146
|
-
>
|
|
147
|
-
<AreasProvider
|
|
148
|
-
onLoad={onLoad}
|
|
149
|
-
activeAreasNetwork={activeAreasNetwork}
|
|
150
|
-
>
|
|
151
|
-
{children}
|
|
152
|
-
</AreasProvider>
|
|
153
|
-
</BaseModule>
|
|
154
|
-
</MFAuthApp>
|
|
155
|
-
</AuthProvider>
|
|
156
|
-
</LocalesProvider>
|
|
157
|
-
</HistoryRouter>
|
|
158
|
-
</NetworkProvider>
|
|
159
|
-
</HostToolsProvider>
|
|
160
|
-
</EnvironmentProvider>
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export default MFIsolationApp;
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
// react
|
|
2
|
-
import { useEffect } from 'react';
|
|
3
|
-
import { format } from 'date-fns';
|
|
4
|
-
//m4l
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
defaultThemeOptions,
|
|
8
|
-
fnComponentsOverrides,
|
|
9
|
-
FormatterProvider,
|
|
10
|
-
HostThemeProvider,
|
|
11
|
-
// ProgressBarStyle,
|
|
12
|
-
} from '@m4l/graphics';
|
|
13
|
-
// external components
|
|
14
|
-
|
|
15
|
-
// mui
|
|
16
|
-
|
|
17
|
-
// internal components
|
|
18
|
-
|
|
19
|
-
// hooks /providers
|
|
20
|
-
|
|
21
|
-
// sub comoponents
|
|
22
|
-
|
|
23
|
-
// types
|
|
24
|
-
|
|
25
|
-
// network
|
|
26
|
-
|
|
27
|
-
// config
|
|
28
|
-
|
|
29
|
-
// utils
|
|
30
|
-
|
|
31
|
-
// css
|
|
32
|
-
|
|
33
|
-
import { useAuth } from '../../../../hooks/useAuth';
|
|
34
|
-
import { MFAuthAppProps } from './types';
|
|
35
|
-
import { ToastContainer } from 'react-toastify';
|
|
36
|
-
import { DomainCountry, DomainCountryProvider } from '@m4l/core';
|
|
37
|
-
|
|
38
|
-
export function MFAuthApp(props: MFAuthAppProps) {
|
|
39
|
-
const { children, user, pwd } = props;
|
|
40
|
-
const { isAuthenticated, isInitialized, login, user: authUser } = useAuth();
|
|
41
|
-
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
// Atenticarse si no lo logro en el paso anterior dado por el efecto de AuthProvider
|
|
44
|
-
|
|
45
|
-
if (isInitialized && isAuthenticated === false) {
|
|
46
|
-
console.log('useEffect MFAuthApp Login');
|
|
47
|
-
login(user, pwd, false);
|
|
48
|
-
}
|
|
49
|
-
}, [isInitialized, isAuthenticated]);
|
|
50
|
-
|
|
51
|
-
if (!isAuthenticated) return <div>Pendiente x atenticar</div>;
|
|
52
|
-
|
|
53
|
-
const domianCountry: DomainCountry = {
|
|
54
|
-
id: 1,
|
|
55
|
-
currency: 'USD',
|
|
56
|
-
currency_decimal_digits: 2,
|
|
57
|
-
decimal_symbol: '.',
|
|
58
|
-
thousands_symbol: ',',
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
if (authUser?.domain_country) {
|
|
62
|
-
domianCountry.id = authUser?.domain_country.id ?? domianCountry.id;
|
|
63
|
-
domianCountry.currency = authUser?.domain_country.currency ?? domianCountry.currency;
|
|
64
|
-
domianCountry.currency_decimal_digits =
|
|
65
|
-
authUser?.domain_country.currency_decimal_digits ??
|
|
66
|
-
domianCountry.currency_decimal_digits;
|
|
67
|
-
domianCountry.decimal_symbol =
|
|
68
|
-
authUser?.domain_country.decimal_symbol ?? domianCountry.decimal_symbol;
|
|
69
|
-
domianCountry.thousands_symbol =
|
|
70
|
-
authUser?.domain_country?.thousands_symbol ?? domianCountry.thousands_symbol;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return (
|
|
74
|
-
<HostThemeProvider
|
|
75
|
-
hostThemeOptions={defaultThemeOptions}
|
|
76
|
-
fnComponentsOverrides={fnComponentsOverrides}
|
|
77
|
-
isMicroFrontEnd={true}
|
|
78
|
-
>
|
|
79
|
-
<ToastContainer />
|
|
80
|
-
<DomainCountryProvider {...domianCountry} isMicroFrontEnd={false}>
|
|
81
|
-
<FormatterProvider
|
|
82
|
-
isMicroFrontEnd={false}
|
|
83
|
-
dateFormatter={{
|
|
84
|
-
formatDate: format,
|
|
85
|
-
}}
|
|
86
|
-
currencyFormatter={{
|
|
87
|
-
code: domianCountry.currency,
|
|
88
|
-
decimalDigits: domianCountry.currency_decimal_digits,
|
|
89
|
-
}}
|
|
90
|
-
>
|
|
91
|
-
{children}
|
|
92
|
-
</FormatterProvider>
|
|
93
|
-
</DomainCountryProvider>
|
|
94
|
-
</HostThemeProvider>
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export default MFAuthApp;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { BaseModuleProps } from '../BaseModule/types';
|
|
2
|
-
|
|
3
|
-
export type MFIsolationAppProps = BaseModuleProps & {
|
|
4
|
-
user: string;
|
|
5
|
-
pwd: string;
|
|
6
|
-
host_api_local: string;
|
|
7
|
-
host_api_remote: string;
|
|
8
|
-
host_static_assets: string;
|
|
9
|
-
environment_assets: string;
|
|
10
|
-
onLoad: () => void;
|
|
11
|
-
activeAreasNetwork?: boolean;
|
|
12
|
-
};
|
package/src/components/index.ts
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
// react
|
|
2
|
-
import { createContext, useEffect, useReducer } from 'react';
|
|
3
|
-
// m4l
|
|
4
|
-
import {
|
|
5
|
-
getLocalStorage,
|
|
6
|
-
setLocalStorage,
|
|
7
|
-
useEnvironment,
|
|
8
|
-
useHostTools,
|
|
9
|
-
useLocalStorageWithListener,
|
|
10
|
-
useNetwork,
|
|
11
|
-
} from '@m4l/core';
|
|
12
|
-
// utils
|
|
13
|
-
|
|
14
|
-
// types
|
|
15
|
-
|
|
16
|
-
import type { AuthProviderProps, AuthState, SessionActions, SessionContextType } from './types';
|
|
17
|
-
|
|
18
|
-
// constants
|
|
19
|
-
import { EnumTypes } from './types';
|
|
20
|
-
import { EmitEvents } from '@m4l/core';
|
|
21
|
-
|
|
22
|
-
const initialState: AuthState = {
|
|
23
|
-
isAuthenticated: false,
|
|
24
|
-
isInitialized: false,
|
|
25
|
-
user: null,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const JWTReducer = (state: AuthState, action: SessionActions) => {
|
|
29
|
-
switch (action.type) {
|
|
30
|
-
case 'INITIALIZE':
|
|
31
|
-
return {
|
|
32
|
-
isAuthenticated: action.payload.isAuthenticated,
|
|
33
|
-
isInitialized: true,
|
|
34
|
-
user: action.payload.user,
|
|
35
|
-
};
|
|
36
|
-
case 'LOGIN':
|
|
37
|
-
return {
|
|
38
|
-
...state,
|
|
39
|
-
isAuthenticated: true,
|
|
40
|
-
user: action.payload.user,
|
|
41
|
-
};
|
|
42
|
-
case 'LOGOUT':
|
|
43
|
-
return {
|
|
44
|
-
...state,
|
|
45
|
-
isAuthenticated: false,
|
|
46
|
-
user: null,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
default:
|
|
50
|
-
return state;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const AuthContext = createContext<SessionContextType | null>(null);
|
|
55
|
-
|
|
56
|
-
// ----------------------------------------------------------------------
|
|
57
|
-
|
|
58
|
-
function dispatchInitial(dispatch: React.Dispatch<SessionActions>) {
|
|
59
|
-
dispatch({
|
|
60
|
-
type: EnumTypes.Initial,
|
|
61
|
-
payload: {
|
|
62
|
-
isAuthenticated: false,
|
|
63
|
-
user: null,
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function AuthProvider(props: AuthProviderProps) {
|
|
69
|
-
const { children } = props;
|
|
70
|
-
const [state, dispatch] = useReducer(JWTReducer, initialState);
|
|
71
|
-
const { events_add_listener } = useHostTools();
|
|
72
|
-
const { networkOperation } = useNetwork();
|
|
73
|
-
const { domain_token } = useEnvironment();
|
|
74
|
-
const [nextValSession, setNextValSession] = useLocalStorageWithListener<string>(
|
|
75
|
-
//Variable para saber si ha cambiado la session en otro navegador
|
|
76
|
-
'vSession',
|
|
77
|
-
new Date().getTime() + '',
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
useEffect(() => {
|
|
81
|
-
//Verifica si el usuario esta logueado
|
|
82
|
-
//Si es por primera vez (No hay localstorage) se envía el lenguage del navegador
|
|
83
|
-
|
|
84
|
-
const initialize = async () => {
|
|
85
|
-
networkOperation({
|
|
86
|
-
method: 'GET',
|
|
87
|
-
endPoint: `auth/login`,
|
|
88
|
-
parms: { user_data: true },
|
|
89
|
-
checkUnAuthorized: false,
|
|
90
|
-
})
|
|
91
|
-
.then(response => {
|
|
92
|
-
// const user_logged: User = response.user;
|
|
93
|
-
|
|
94
|
-
dispatch({
|
|
95
|
-
type: EnumTypes.Initial,
|
|
96
|
-
payload: {
|
|
97
|
-
isAuthenticated: true,
|
|
98
|
-
user: response.user,
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
//requintar el localstorage por si cambia externamente
|
|
102
|
-
const useSaved = getLocalStorage('userData', {
|
|
103
|
-
email: response.user.email,
|
|
104
|
-
remember: true,
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
if (useSaved?.email !== response.user.email) {
|
|
108
|
-
//Si cambiaron el usuario
|
|
109
|
-
setLocalStorage('userData', { email: response.user.email }, true);
|
|
110
|
-
}
|
|
111
|
-
})
|
|
112
|
-
.catch(() => {
|
|
113
|
-
//No está logueado
|
|
114
|
-
dispatchInitial(dispatch);
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
initialize();
|
|
119
|
-
|
|
120
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
121
|
-
}, [nextValSession]);
|
|
122
|
-
|
|
123
|
-
const login = async (email: string, password: string, remember: boolean) => {
|
|
124
|
-
await networkOperation({
|
|
125
|
-
endPoint: `auth/login`,
|
|
126
|
-
method: 'POST',
|
|
127
|
-
data: {
|
|
128
|
-
email,
|
|
129
|
-
password,
|
|
130
|
-
domain_token,
|
|
131
|
-
},
|
|
132
|
-
}).then(response => {
|
|
133
|
-
const user = response.data;
|
|
134
|
-
|
|
135
|
-
if (remember) {
|
|
136
|
-
setLocalStorage('userData', { email, remember });
|
|
137
|
-
} else {
|
|
138
|
-
setLocalStorage('userData', { email: '', remember });
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
dispatch({
|
|
142
|
-
type: EnumTypes.Login,
|
|
143
|
-
payload: {
|
|
144
|
-
user,
|
|
145
|
-
},
|
|
146
|
-
});
|
|
147
|
-
setNextValSession(new Date().getTime() + '');
|
|
148
|
-
});
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const logout = async (isAuthenticated: boolean) => {
|
|
152
|
-
if (isAuthenticated) {
|
|
153
|
-
await networkOperation({
|
|
154
|
-
endPoint: `auth/logout`,
|
|
155
|
-
method: 'POST',
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
dispatch({ type: EnumTypes.Logout });
|
|
159
|
-
setNextValSession(new Date().getTime() + '');
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
const onNetserviceUnautorized = () => {
|
|
163
|
-
logout(false);
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
useEffect(() => {
|
|
167
|
-
//Verifica si el usuario esta logueado
|
|
168
|
-
|
|
169
|
-
events_add_listener(
|
|
170
|
-
EmitEvents.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED,
|
|
171
|
-
onNetserviceUnautorized,
|
|
172
|
-
);
|
|
173
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
174
|
-
}, []);
|
|
175
|
-
|
|
176
|
-
return (
|
|
177
|
-
<AuthContext.Provider
|
|
178
|
-
value={{
|
|
179
|
-
...state,
|
|
180
|
-
login,
|
|
181
|
-
logout,
|
|
182
|
-
}}
|
|
183
|
-
>
|
|
184
|
-
{children}
|
|
185
|
-
</AuthContext.Provider>
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export { AuthContext, AuthProvider };
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { DomainCountry, Maybe } from '@m4l/core';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
|
|
4
|
-
// eslint-disable-next-line no-shadow
|
|
5
|
-
export enum EnumTypes {
|
|
6
|
-
Initial = 'INITIALIZE',
|
|
7
|
-
Login = 'LOGIN',
|
|
8
|
-
Logout = 'LOGOUT',
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type AuthProviderProps = {
|
|
12
|
-
children: ReactNode;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export type ActionMap<M extends { [index: string]: any }> = {
|
|
16
|
-
[Key in keyof M]: M[Key] extends undefined
|
|
17
|
-
? {
|
|
18
|
-
type: Key;
|
|
19
|
-
}
|
|
20
|
-
: {
|
|
21
|
-
type: Key;
|
|
22
|
-
payload: M[Key];
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type SessionAuthPayload = {
|
|
27
|
-
[EnumTypes.Initial]: {
|
|
28
|
-
isAuthenticated: boolean;
|
|
29
|
-
user: AuthUser;
|
|
30
|
-
};
|
|
31
|
-
[EnumTypes.Login]: {
|
|
32
|
-
user: AuthUser;
|
|
33
|
-
};
|
|
34
|
-
[EnumTypes.Logout]: undefined;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export type SessionActions = ActionMap<SessionAuthPayload>[keyof ActionMap<SessionAuthPayload>];
|
|
38
|
-
|
|
39
|
-
// export type AuthStoreState = {
|
|
40
|
-
// user: User;
|
|
41
|
-
// remember?: boolean;
|
|
42
|
-
// };
|
|
43
|
-
|
|
44
|
-
export interface User {
|
|
45
|
-
email: string;
|
|
46
|
-
id: number;
|
|
47
|
-
first_name: string;
|
|
48
|
-
last_name: string;
|
|
49
|
-
account_id: number;
|
|
50
|
-
domain_country: DomainCountry;
|
|
51
|
-
avatar_url?: Maybe<string>;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export type AuthUser = Maybe<User>;
|
|
55
|
-
|
|
56
|
-
export type AuthState = {
|
|
57
|
-
isAuthenticated: boolean;
|
|
58
|
-
isInitialized: boolean;
|
|
59
|
-
user: AuthUser;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export interface SessionContextType extends AuthState {
|
|
63
|
-
login: (email: string, password: string, remember: boolean) => object | undefined;
|
|
64
|
-
logout: (isAuthenticated: boolean) => Promise<void>;
|
|
65
|
-
}
|
package/src/contexts/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './AuthContext';
|
package/src/hooks/index.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useContext } from 'react';
|
|
2
|
-
import { AuthContext } from '../../contexts/AuthContext';
|
|
3
|
-
|
|
4
|
-
export const useAuth = () => {
|
|
5
|
-
const context = useContext(AuthContext);
|
|
6
|
-
|
|
7
|
-
if (!context) throw new Error('Auth context must be use inside AuthProvider');
|
|
8
|
-
|
|
9
|
-
return context;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default useAuth;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { useContext } from 'react';
|
|
2
|
-
import { MasterDetailContext } from '../../layouts/MasterDetailLayout/contexts/MasterDetailContext';
|
|
3
|
-
|
|
4
|
-
// ----------------------------------------------------------------------
|
|
5
|
-
|
|
6
|
-
export const useMasterDetail = () => useContext(MasterDetailContext);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { useContext } from 'react';
|
|
2
|
-
import { ModuleContext } from '../../layouts/ModuleLayout/contexts/ModuleContext';
|
|
3
|
-
|
|
4
|
-
// ----------------------------------------------------------------------
|
|
5
|
-
export const useModule = () => {
|
|
6
|
-
const context = useContext(ModuleContext);
|
|
7
|
-
|
|
8
|
-
if (!context) throw new Error('useModule context must be use inside ModuleContext');
|
|
9
|
-
|
|
10
|
-
return context;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default useModule;
|
package/src/index.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// react
|
|
2
|
-
|
|
3
|
-
// mui
|
|
4
|
-
import { Button } from '@mui/material';
|
|
5
|
-
import { ComponentActionProps } from '@m4l/components';
|
|
6
|
-
import { useMasterDetail } from '../../../../hooks/useMasterDetail';
|
|
7
|
-
|
|
8
|
-
// external libraries
|
|
9
|
-
|
|
10
|
-
// componentes estilados
|
|
11
|
-
|
|
12
|
-
// sub components
|
|
13
|
-
|
|
14
|
-
// dictionary
|
|
15
|
-
|
|
16
|
-
// context
|
|
17
|
-
|
|
18
|
-
// hooks
|
|
19
|
-
|
|
20
|
-
// types
|
|
21
|
-
|
|
22
|
-
// constants
|
|
23
|
-
|
|
24
|
-
export function ButtonDetail(props: ComponentActionProps) {
|
|
25
|
-
const { masterSelection } = useMasterDetail();
|
|
26
|
-
const { onClick, description } = props;
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<Button
|
|
30
|
-
key="miDetail"
|
|
31
|
-
onClick={onClick}
|
|
32
|
-
variant="outlined"
|
|
33
|
-
disabled={masterSelection === undefined ? true : false}
|
|
34
|
-
>
|
|
35
|
-
{description}
|
|
36
|
-
</Button>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// react
|
|
2
|
-
import { createContext, useState } from 'react';
|
|
3
|
-
import { voidFunction } from '@m4l/core';
|
|
4
|
-
|
|
5
|
-
// types
|
|
6
|
-
import { MasterDetailContextProps, MasterDetailProviderProps, MasterSelecion } from './types';
|
|
7
|
-
|
|
8
|
-
const initialState: MasterDetailContextProps = {
|
|
9
|
-
masterSelection: undefined,
|
|
10
|
-
onChangeMasterSelection: voidFunction,
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const MasterDetailContext = createContext<MasterDetailContextProps>(initialState);
|
|
14
|
-
|
|
15
|
-
// ----------------------------------------------------------------------
|
|
16
|
-
|
|
17
|
-
function MasterDetailProvider(props: MasterDetailProviderProps) {
|
|
18
|
-
const { children } = props;
|
|
19
|
-
|
|
20
|
-
const [masterSelection, setMasterSelection] = useState<MasterSelecion>(undefined);
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<MasterDetailContext.Provider
|
|
24
|
-
value={{
|
|
25
|
-
masterSelection,
|
|
26
|
-
onChangeMasterSelection: setMasterSelection,
|
|
27
|
-
}}
|
|
28
|
-
>
|
|
29
|
-
{children}
|
|
30
|
-
</MasterDetailContext.Provider>
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { MasterDetailProvider, MasterDetailContext };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
export type MasterSelecion = any | any[] | undefined;
|
|
4
|
-
|
|
5
|
-
export interface MasterDetailContextStateProps {
|
|
6
|
-
masterSelection?: MasterSelecion;
|
|
7
|
-
// splitPosition?: SplitPosition;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface MasterDetailProviderProps {
|
|
11
|
-
// masterSelection: MasterSelecion;
|
|
12
|
-
// setMasterSelection: (newMasterSelecion: MasterSelecion) => void;
|
|
13
|
-
children: ReactNode;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface MasterDetailContextProps extends MasterDetailContextStateProps {
|
|
17
|
-
onChangeMasterSelection: (newMasterSelection: MasterSelecion) => void;
|
|
18
|
-
// onChangeSplitPosition: (newMasterSelection: MasterSelecion) => void;
|
|
19
|
-
}
|