@m4l/layouts 0.1.26 → 0.1.30

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 (133) hide show
  1. package/{dist/components/MFIsolationApp/index.b21e5671.js → components/MFIsolationApp/index.b89e6800.js} +38 -37
  2. package/{dist/components/index.deb4e7ac.js → components/index.37205bf4.js} +1 -1
  3. package/index.js +42 -0
  4. package/m4l_layouts/types.d.ts +0 -0
  5. package/package.json +10 -53
  6. package/.eslintignore +0 -2
  7. package/.eslintrc.cjs +0 -118
  8. package/.gitignore +0 -23
  9. package/.gitlab-ci.yml +0 -16
  10. package/.prettierignore +0 -3
  11. package/.prettierrc.json +0 -26
  12. package/.vscode/settings.json +0 -50
  13. package/dist/index.js +0 -41
  14. package/dist/package.json +0 -36
  15. package/src/@types/index.ts +0 -8
  16. package/src/components/BaseModule/index.tsx +0 -59
  17. package/src/components/BaseModule/types.ts +0 -12
  18. package/src/components/MFHostApp/index.tsx +0 -95
  19. package/src/components/MFHostApp/types.ts +0 -16
  20. package/src/components/MFIsolationApp/index.tsx +0 -164
  21. package/src/components/MFIsolationApp/subcomponents/MFAuthApp/index.tsx +0 -98
  22. package/src/components/MFIsolationApp/subcomponents/MFAuthApp/types.ts +0 -7
  23. package/src/components/MFIsolationApp/types.ts +0 -12
  24. package/src/components/index.ts +0 -5
  25. package/src/contexts/AuthContext/index.tsx +0 -189
  26. package/src/contexts/AuthContext/types.ts +0 -65
  27. package/src/contexts/index.ts +0 -1
  28. package/src/hooks/index.ts +0 -5
  29. package/src/hooks/useAuth/index.ts +0 -12
  30. package/src/hooks/useMasterDetail/index.ts +0 -6
  31. package/src/hooks/useModule/index.ts +0 -13
  32. package/src/index.ts +0 -7
  33. package/src/layouts/MasterDetailLayout/components/ButtonDetail/index.tsx +0 -38
  34. package/src/layouts/MasterDetailLayout/contexts/MasterDetailContext/index.tsx +0 -34
  35. package/src/layouts/MasterDetailLayout/contexts/MasterDetailContext/types.ts +0 -19
  36. package/src/layouts/MasterDetailLayout/dicctionary.ts +0 -20
  37. package/src/layouts/MasterDetailLayout/index.tsx +0 -165
  38. package/src/layouts/MasterDetailLayout/types.ts +0 -11
  39. package/src/layouts/ModuleLayout/contexts/ModuleContext/index.tsx +0 -56
  40. package/src/layouts/ModuleLayout/contexts/ModuleContext/types.ts +0 -23
  41. package/src/layouts/ModuleLayout/dicctionary.ts +0 -11
  42. package/src/layouts/ModuleLayout/index.tsx +0 -59
  43. package/src/layouts/ModuleLayout/subcomponents/InnerModule/index.tsx +0 -35
  44. package/src/layouts/ModuleLayout/subcomponents/InnerModule/styles.tsx +0 -31
  45. package/src/layouts/ModuleLayout/subcomponents/InnerModule/types.ts +0 -11
  46. package/src/layouts/ModuleLayout/types.ts +0 -31
  47. package/src/layouts/NoAuthModuleLayout/dicctionary.ts +0 -9
  48. package/src/layouts/NoAuthModuleLayout/index.tsx +0 -85
  49. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/index.tsx +0 -43
  50. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/styles.tsx +0 -6
  51. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/index.tsx +0 -14
  52. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/styles.tsx +0 -7
  53. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/AppBar/index.tsx +0 -25
  54. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/AppBar/styles.tsx +0 -11
  55. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/index.tsx +0 -17
  56. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/styles.tsx +0 -19
  57. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/subcomponents/NameDescription/index.tsx +0 -25
  58. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/subcomponents/NameDescription/styles.tsx +0 -8
  59. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/types.ts +0 -5
  60. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/types.ts +0 -5
  61. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/LogoLeyend/index.tsx +0 -28
  62. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/LogoLeyend/styles.tsx +0 -16
  63. package/src/layouts/NoAuthModuleLayout/subcomponents/InnerModule/types.ts +0 -5
  64. package/src/layouts/NoAuthModuleLayout/types.ts +0 -22
  65. package/src/layouts/index.ts +0 -8
  66. package/src/test/setup.ts +0 -1
  67. package/src/test/utils.tsx +0 -20
  68. package/src/vite-env.d.ts +0 -3
  69. package/tsconfig.json +0 -29
  70. package/tsconfig.node.json +0 -8
  71. package/vite.config.ts +0 -172
  72. /package/{dist/components → components}/BaseModule/index.6309486a.js +0 -0
  73. /package/{dist/components → components}/BaseModule/index.d.ts +0 -0
  74. /package/{dist/components → components}/BaseModule/types.d.ts +0 -0
  75. /package/{dist/components → components}/MFHostApp/index.1700d13a.js +0 -0
  76. /package/{dist/components → components}/MFHostApp/index.d.ts +0 -0
  77. /package/{dist/components → components}/MFHostApp/types.d.ts +0 -0
  78. /package/{dist/components → components}/MFIsolationApp/index.d.ts +0 -0
  79. /package/{dist/components → components}/MFIsolationApp/subcomponents/MFAuthApp/index.d.ts +0 -0
  80. /package/{dist/components → components}/MFIsolationApp/subcomponents/MFAuthApp/types.d.ts +0 -0
  81. /package/{dist/components → components}/MFIsolationApp/types.d.ts +0 -0
  82. /package/{dist/components → components}/index.d.ts +0 -0
  83. /package/{dist/contexts → contexts}/AuthContext/index.6f966215.js +0 -0
  84. /package/{dist/contexts → contexts}/AuthContext/index.d.ts +0 -0
  85. /package/{dist/contexts → contexts}/AuthContext/types.d.ts +0 -0
  86. /package/{dist/contexts → contexts}/index.b46a2699.js +0 -0
  87. /package/{dist/contexts → contexts}/index.d.ts +0 -0
  88. /package/{dist/hooks → hooks}/index.2022a179.js +0 -0
  89. /package/{dist/hooks → hooks}/index.d.ts +0 -0
  90. /package/{dist/hooks → hooks}/useAuth/index.cb6a3420.js +0 -0
  91. /package/{dist/hooks → hooks}/useAuth/index.d.ts +0 -0
  92. /package/{dist/hooks → hooks}/useMasterDetail/index.1b024fd5.js +0 -0
  93. /package/{dist/hooks → hooks}/useMasterDetail/index.d.ts +0 -0
  94. /package/{dist/hooks → hooks}/useModule/index.6ff7d08a.js +0 -0
  95. /package/{dist/hooks → hooks}/useModule/index.d.ts +0 -0
  96. /package/{dist/index.d.ts → index.d.ts} +0 -0
  97. /package/{dist/layouts → layouts}/MasterDetailLayout/contexts/MasterDetailContext/index.d.ts +0 -0
  98. /package/{dist/layouts → layouts}/MasterDetailLayout/contexts/MasterDetailContext/types.d.ts +0 -0
  99. /package/{dist/layouts → layouts}/MasterDetailLayout/dicctionary.d.ts +0 -0
  100. /package/{dist/layouts → layouts}/MasterDetailLayout/index.3da0ffda.js +0 -0
  101. /package/{dist/layouts → layouts}/MasterDetailLayout/index.d.ts +0 -0
  102. /package/{dist/layouts → layouts}/MasterDetailLayout/types.d.ts +0 -0
  103. /package/{dist/layouts → layouts}/ModuleLayout/contexts/ModuleContext/index.d.ts +0 -0
  104. /package/{dist/layouts → layouts}/ModuleLayout/contexts/ModuleContext/types.d.ts +0 -0
  105. /package/{dist/layouts → layouts}/ModuleLayout/dicctionary.d.ts +0 -0
  106. /package/{dist/layouts → layouts}/ModuleLayout/index.a76397df.js +0 -0
  107. /package/{dist/layouts → layouts}/ModuleLayout/index.d.ts +0 -0
  108. /package/{dist/layouts → layouts}/ModuleLayout/subcomponents/InnerModule/index.d.ts +0 -0
  109. /package/{dist/layouts → layouts}/ModuleLayout/subcomponents/InnerModule/styles.d.ts +0 -0
  110. /package/{dist/layouts → layouts}/ModuleLayout/subcomponents/InnerModule/types.d.ts +0 -0
  111. /package/{dist/layouts → layouts}/ModuleLayout/types.d.ts +0 -0
  112. /package/{dist/layouts → layouts}/NoAuthModuleLayout/dicctionary.d.ts +0 -0
  113. /package/{dist/layouts → layouts}/NoAuthModuleLayout/index.5d1098ef.js +0 -0
  114. /package/{dist/layouts → layouts}/NoAuthModuleLayout/index.d.ts +0 -0
  115. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/index.d.ts +0 -0
  116. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/styles.d.ts +0 -0
  117. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/index.d.ts +0 -0
  118. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/styles.d.ts +0 -0
  119. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/AppBar/index.d.ts +0 -0
  120. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/AppBar/styles.d.ts +0 -0
  121. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/index.d.ts +0 -0
  122. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/styles.d.ts +0 -0
  123. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/subcomponents/NameDescription/index.d.ts +0 -0
  124. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/subcomponents/NameDescription/styles.d.ts +0 -0
  125. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/subcomponents/Form/types.d.ts +0 -0
  126. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/AppBarForm/types.d.ts +0 -0
  127. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/LogoLeyend/index.d.ts +0 -0
  128. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/subcomponents/LogoLeyend/styles.d.ts +0 -0
  129. /package/{dist/layouts → layouts}/NoAuthModuleLayout/subcomponents/InnerModule/types.d.ts +0 -0
  130. /package/{dist/layouts → layouts}/NoAuthModuleLayout/types.d.ts +0 -0
  131. /package/{dist/layouts → layouts}/index.014e41ba.js +0 -0
  132. /package/{dist/layouts → layouts}/index.d.ts +0 -0
  133. /package/{dist/vite-env.d.ts → vite-env.d.ts} +0 -0
@@ -1,59 +0,0 @@
1
- // react
2
-
3
- //m4l
4
-
5
- import { ModalProvider } from '@m4l/components';
6
- import {
7
- FlagsProvider,
8
- ModuleDictionaryProvider,
9
- ModulePrivilegesProvider,
10
- ModuleSkeletonProvider,
11
- } from '@m4l/core';
12
- // external components
13
-
14
- // mui
15
- // internal components
16
- // hooks /providers
17
-
18
- // sub comoponents
19
-
20
- // types
21
- import { BaseModuleProps } from './types';
22
- // network
23
-
24
- // config
25
-
26
- // utils
27
-
28
- // css
29
-
30
- export function BaseModule(props: BaseModuleProps) {
31
- const {
32
- children,
33
-
34
- moduleId,
35
- moduleNameField,
36
- skeletonFlags,
37
- privileges,
38
- componentsDictionary,
39
- } = props;
40
-
41
- return (
42
- <FlagsProvider>
43
- <ModuleDictionaryProvider
44
- isAuth={true}
45
- moduleId={moduleId}
46
- moduleNameField={moduleNameField}
47
- componentsDictionary={componentsDictionary}
48
- >
49
- <ModuleSkeletonProvider flags={skeletonFlags}>
50
- <ModulePrivilegesProvider queryPrivileges={privileges}>
51
- <ModalProvider>{children}</ModalProvider>
52
- </ModulePrivilegesProvider>
53
- </ModuleSkeletonProvider>
54
- </ModuleDictionaryProvider>
55
- </FlagsProvider>
56
- );
57
- }
58
-
59
- export default BaseModule;
@@ -1,12 +0,0 @@
1
- import { ReactNode } from 'react';
2
-
3
- export type BaseModuleProps = {
4
- //Parametros del modulo
5
- moduleId: string;
6
- skeletonFlags: string[];
7
- moduleNameField?: string;
8
- privileges: string[];
9
- componentsDictionary: string[];
10
-
11
- children: ReactNode;
12
- };
@@ -1,95 +0,0 @@
1
- // react
2
- import { unstable_HistoryRouter as HistoryRouter } from 'react-router-dom';
3
-
4
- //m4l
5
- import {
6
- DomainCountryProvider,
7
- EnvironmentProvider,
8
- HostToolsProvider,
9
- NetworkProvider,
10
- } from '@m4l/core';
11
- import { FormatterProvider, HostThemeProvider, LocalesProvider } from '@m4l/graphics';
12
-
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 { MFHostAppProps } from './types';
34
-
35
- import BaseModule from '../BaseModule';
36
- import { DynamicMFParmsProvider } from '@m4l/components';
37
-
38
- export function MFHostApp(props: MFHostAppProps) {
39
- const {
40
- children,
41
- currentLocale,
42
- hostTheme,
43
- environment,
44
- hostTools,
45
- axiosOperation,
46
- formatters,
47
- dynamicMFParameters,
48
- moduleId,
49
- moduleNameField,
50
- skeletonFlags,
51
- privileges,
52
- componentsDictionary,
53
- } = props;
54
-
55
- return (
56
- <EnvironmentProvider {...environment}>
57
- <HostToolsProvider {...hostTools}>
58
- <NetworkProvider axiosOperation={axiosOperation}>
59
- <LocalesProvider isMicroFrontEnd localeHost={currentLocale}>
60
- <HostThemeProvider isMicroFrontEnd={true} {...hostTheme}>
61
- <HistoryRouter history={hostTools.history}>
62
- <DomainCountryProvider
63
- isMicroFrontEnd
64
- id={dynamicMFParameters?.id || 1}
65
- currency={formatters.currencyFormatter.code}
66
- currency_decimal_digits={
67
- formatters.currencyFormatter.decimalDigits
68
- }
69
- decimal_symbol={formatters.numberFormatter.decimalSymbol}
70
- thousands_symbol={formatters.numberFormatter.thousandsSymbol}
71
- >
72
- <BaseModule
73
- moduleId={moduleId}
74
- moduleNameField={moduleNameField}
75
- componentsDictionary={componentsDictionary}
76
- skeletonFlags={skeletonFlags}
77
- privileges={privileges}
78
- >
79
- <FormatterProvider isMicroFrontEnd {...formatters}>
80
- <DynamicMFParmsProvider {...dynamicMFParameters}>
81
- {children}
82
- </DynamicMFParmsProvider>
83
- </FormatterProvider>
84
- </BaseModule>
85
- </DomainCountryProvider>
86
- </HistoryRouter>
87
- </HostThemeProvider>
88
- </LocalesProvider>
89
- </NetworkProvider>
90
- </HostToolsProvider>
91
- </EnvironmentProvider>
92
- );
93
- }
94
-
95
- export default MFHostApp;
@@ -1,16 +0,0 @@
1
- import type { AxiosOperation, EnvironmentType, HostToolsType } from '@m4l/core';
2
- import { Formatters, HostThemeType, LocaleType } from '@m4l/graphics';
3
- import { DynamicMFParameters } from '@m4l/components';
4
- import { BaseModuleProps } from '../BaseModule/types';
5
-
6
- export interface ByHostProps {
7
- environment: EnvironmentType;
8
- hostTools: HostToolsType;
9
- hostTheme: HostThemeType;
10
- currentLocale: LocaleType;
11
- axiosOperation: AxiosOperation;
12
- formatters: Formatters;
13
- dynamicMFParameters: DynamicMFParameters;
14
- }
15
-
16
- export type MFHostAppProps = ByHostProps & BaseModuleProps;
@@ -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,7 +0,0 @@
1
- import { ReactNode } from 'react';
2
-
3
- export type MFAuthAppProps = {
4
- user: string;
5
- pwd: string;
6
- children: ReactNode;
7
- };
@@ -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
- };
@@ -1,5 +0,0 @@
1
- export { MFIsolationApp } from './MFIsolationApp';
2
- export { MFHostApp } from './MFHostApp';
3
- export { BaseModule } from './BaseModule';
4
-
5
- export type { ByHostProps } from './MFHostApp/types';
@@ -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 };