@chimera-pe/react-saas 0.0.11 → 0.1.2
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/dist/react-saas.js +537 -276
- package/dist/react-saas.umd.cjs +1 -1
- package/package.json +2 -1
package/dist/react-saas.js
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Box as
|
|
3
|
-
import { useTranslate as
|
|
4
|
-
import
|
|
5
|
-
import { useDispatch as
|
|
6
|
-
import { createSlice as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { useState as
|
|
10
|
-
import { enGB as
|
|
11
|
-
import { LocalizationProvider as
|
|
12
|
-
import { AdapterDateFns as
|
|
13
|
-
import
|
|
14
|
-
import { createTheme as
|
|
15
|
-
import { grey as
|
|
16
|
-
import { useLocation as
|
|
17
|
-
import { Email as
|
|
18
|
-
import { Form as
|
|
19
|
-
import { TextField as
|
|
20
|
-
const
|
|
1
|
+
import { jsx as o, jsxs as d, Fragment as $e } from "react/jsx-runtime";
|
|
2
|
+
import { Box as $, CircularProgress as X, Alert as Q, AlertTitle as xe, Snackbar as Te, useMediaQuery as we, CssBaseline as Se, Container as je, Grid as g, Typography as A, Card as Oe, CardHeader as Re, CardContent as ke, AppBar as ze, Toolbar as De, Link as Ie, InputAdornment as G, Button as Ae } from "@mui/material";
|
|
3
|
+
import { useTranslate as j, I18n as Le } from "react-polyglot";
|
|
4
|
+
import i from "prop-types";
|
|
5
|
+
import { useDispatch as m, useSelector as u, Provider as Pe } from "react-redux";
|
|
6
|
+
import { createSlice as O, createAsyncThunk as q, configureStore as Ne } from "@reduxjs/toolkit";
|
|
7
|
+
import N from "axios";
|
|
8
|
+
import qe from "jwt-decode";
|
|
9
|
+
import { useState as Fe, useEffect as v, useMemo as Me, useCallback as Ge } from "react";
|
|
10
|
+
import { enGB as Ee, es as He } from "date-fns/locale";
|
|
11
|
+
import { LocalizationProvider as Ue } from "@mui/x-date-pickers";
|
|
12
|
+
import { AdapterDateFns as Be } from "@mui/x-date-pickers/AdapterDateFns";
|
|
13
|
+
import Ve from "navigator-languages";
|
|
14
|
+
import { createTheme as Ke, ThemeProvider as Je } from "@mui/material/styles";
|
|
15
|
+
import { grey as E } from "@mui/material/colors";
|
|
16
|
+
import { useLocation as Y, Navigate as ee, BrowserRouter as Ze, Routes as We, Route as H } from "react-router-dom";
|
|
17
|
+
import { Email as Xe, Lock as Qe } from "@mui/icons-material";
|
|
18
|
+
import { Form as Ye } from "react-final-form";
|
|
19
|
+
import { TextField as U } from "mui-rff";
|
|
20
|
+
const er = () => /* @__PURE__ */ o($, { sx: {
|
|
21
21
|
display: "flex",
|
|
22
22
|
flexDirection: "column",
|
|
23
23
|
flexGrow: 1,
|
|
24
24
|
justifyContent: "center",
|
|
25
25
|
alignItems: "center"
|
|
26
|
-
}, children: /* @__PURE__ */
|
|
27
|
-
const n =
|
|
28
|
-
return /* @__PURE__ */
|
|
26
|
+
}, children: /* @__PURE__ */ o(X, {}) }), rr = ({ titulo: e, texto: r, align: t = "center", severity: a = "error" }) => {
|
|
27
|
+
const n = j();
|
|
28
|
+
return /* @__PURE__ */ o($, { sx: {
|
|
29
29
|
display: "flex",
|
|
30
30
|
flexDirection: "column",
|
|
31
31
|
flexGrow: 1,
|
|
32
32
|
justifyContent: "center",
|
|
33
|
-
alignItems:
|
|
34
|
-
}, children: /* @__PURE__ */ d(
|
|
35
|
-
/* @__PURE__ */
|
|
36
|
-
|
|
33
|
+
alignItems: t
|
|
34
|
+
}, children: /* @__PURE__ */ d(Q, { severity: a, children: [
|
|
35
|
+
/* @__PURE__ */ o(xe, { children: n(e) }),
|
|
36
|
+
r && n(r)
|
|
37
37
|
] }) });
|
|
38
38
|
};
|
|
39
39
|
Error.propTypes = {
|
|
40
|
-
titulo:
|
|
41
|
-
texto:
|
|
42
|
-
align:
|
|
43
|
-
severity:
|
|
40
|
+
titulo: i.string.isRequired,
|
|
41
|
+
texto: i.string,
|
|
42
|
+
align: i.string,
|
|
43
|
+
severity: i.string
|
|
44
44
|
};
|
|
45
|
-
const
|
|
45
|
+
const re = O({
|
|
46
46
|
name: "ui",
|
|
47
47
|
initialState: {
|
|
48
48
|
tema: "light",
|
|
@@ -50,40 +50,40 @@ const _ = k({
|
|
|
50
50
|
idioma: "es"
|
|
51
51
|
},
|
|
52
52
|
reducers: {
|
|
53
|
-
cambiarTema: (
|
|
54
|
-
|
|
53
|
+
cambiarTema: (e, r) => {
|
|
54
|
+
e.tema = r.payload, e.temaSeleccionado = !0, localStorage.setItem("tema", r.payload);
|
|
55
55
|
},
|
|
56
|
-
cambiarIdioma: (
|
|
57
|
-
|
|
56
|
+
cambiarIdioma: (e, r) => {
|
|
57
|
+
e.idioma = r.payload;
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
}), { cambiarTema:
|
|
61
|
-
login: (
|
|
62
|
-
url: `${
|
|
60
|
+
}), { cambiarTema: tr, cambiarIdioma: ar } = re.actions, nr = re.reducer, or = "https://saas.chimera.com.pe/backend", ir = "https://saas.chimera.com.pe/oauth", te = (e = ir) => ({
|
|
61
|
+
login: (r, t) => N({
|
|
62
|
+
url: `${e}/oauth/token`,
|
|
63
63
|
headers: {
|
|
64
64
|
"content-type": "application/x-www-form-urlencoded",
|
|
65
|
-
Authorization: `Basic ${
|
|
65
|
+
Authorization: `Basic ${r}`
|
|
66
66
|
},
|
|
67
67
|
method: "post",
|
|
68
68
|
data: {
|
|
69
|
-
username:
|
|
70
|
-
password:
|
|
69
|
+
username: t.correo,
|
|
70
|
+
password: t.password,
|
|
71
71
|
grant_type: "password"
|
|
72
72
|
}
|
|
73
73
|
}),
|
|
74
|
-
refreshToken: (
|
|
75
|
-
url: `${
|
|
74
|
+
refreshToken: (r, t) => N({
|
|
75
|
+
url: `${e}/oauth/token`,
|
|
76
76
|
headers: {
|
|
77
77
|
"content-type": "application/x-www-form-urlencoded",
|
|
78
|
-
Authorization: `Basic ${
|
|
78
|
+
Authorization: `Basic ${r}`
|
|
79
79
|
},
|
|
80
80
|
method: "post",
|
|
81
81
|
data: {
|
|
82
|
-
refresh_token:
|
|
82
|
+
refresh_token: t,
|
|
83
83
|
grant_type: "refresh_token"
|
|
84
84
|
}
|
|
85
85
|
})
|
|
86
|
-
}),
|
|
86
|
+
}), ae = O({
|
|
87
87
|
name: "login",
|
|
88
88
|
initialState: {
|
|
89
89
|
cargando: !1,
|
|
@@ -96,107 +96,107 @@ const _ = k({
|
|
|
96
96
|
error: null
|
|
97
97
|
},
|
|
98
98
|
reducers: {
|
|
99
|
-
logout: (
|
|
100
|
-
|
|
99
|
+
logout: (e) => {
|
|
100
|
+
e.cargando = !1, e.autenticado = !1, e.token = null, e.refreshToken = null, e.expiracion = null, e.usuario = null, e.perfiles = [], e.error = null;
|
|
101
101
|
}
|
|
102
102
|
},
|
|
103
|
-
extraReducers(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}).addCase(
|
|
107
|
-
const a =
|
|
108
|
-
c.setSeconds(c.getSeconds() +
|
|
109
|
-
}).addCase(
|
|
103
|
+
extraReducers(e) {
|
|
104
|
+
e.addCase(T.pending, (r) => {
|
|
105
|
+
r.cargando = !0, r.error = null;
|
|
106
|
+
}).addCase(T.fulfilled, (r, t) => {
|
|
107
|
+
const a = t.payload.access_token, n = qe(a), c = /* @__PURE__ */ new Date();
|
|
108
|
+
c.setSeconds(c.getSeconds() + t.payload.expires_in), r.cargando = !1, r.autenticado = !0, r.token = a, r.refreshToken = t.payload.refresh_token, r.expiracion = c.getTime(), r.usuario = n.name, r.perfiles = n.authorities;
|
|
109
|
+
}).addCase(T.rejected, (r, t) => {
|
|
110
110
|
var a;
|
|
111
|
-
console.log(
|
|
112
|
-
}).addCase(
|
|
113
|
-
|
|
114
|
-
}).addCase(
|
|
111
|
+
console.log(t), r.cargando = !1, r.autenticado = !1, r.token = null, r.refreshToken = null, r.expiracion = null, r.usuario = null, r.perfiles = [], r.error = (a = t.error) == null ? void 0 : a.message;
|
|
112
|
+
}).addCase(w.pending, (r) => {
|
|
113
|
+
r.cargando = !0;
|
|
114
|
+
}).addCase(w.fulfilled, (r, t) => {
|
|
115
115
|
const a = /* @__PURE__ */ new Date();
|
|
116
|
-
a.setSeconds(a.getSeconds() +
|
|
117
|
-
}).addCase(
|
|
116
|
+
a.setSeconds(a.getSeconds() + t.payload.expires_in), r.token = t.payload.access_token, r.refreshToken = t.payload.refresh_token, r.expiracion = a.getTime();
|
|
117
|
+
}).addCase(w.rejected, (r, t) => {
|
|
118
118
|
var a;
|
|
119
|
-
|
|
119
|
+
r.cargando = !1, r.autenticado = !1, r.token = null, r.refreshToken = null, r.expiracion = null, r.usuario = null, r.perfiles = [], r.error = (a = t.error) == null ? void 0 : a.message;
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
|
-
}),
|
|
122
|
+
}), T = q("login/requestToken", async (e) => (await te(e.devURL).login(e.clientCredentials, e.data)).data), w = q("login/refreshToken", async (e, r, t) => (await te(e).refreshToken(r, t)).data), { logout: sr } = ae.actions, Sn = (e) => e.token, jn = (e) => e.usuario, On = (e) => e.perfiles, cr = ae.reducer, ne = O({
|
|
123
123
|
name: "notificacion",
|
|
124
124
|
initialState: [],
|
|
125
125
|
reducers: {
|
|
126
|
-
mostrarNotificacion: (
|
|
127
|
-
|
|
126
|
+
mostrarNotificacion: (e, r) => {
|
|
127
|
+
e.push(r.payload);
|
|
128
128
|
},
|
|
129
|
-
ocultarNotificacion: (
|
|
130
|
-
|
|
129
|
+
ocultarNotificacion: (e) => {
|
|
130
|
+
e.pop();
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
}), { mostrarNotificacion:
|
|
134
|
-
url: `${
|
|
133
|
+
}), { mostrarNotificacion: lr, ocultarNotificacion: dr } = ne.actions, ur = ne.reducer, pr = (e = or, r) => N({
|
|
134
|
+
url: `${e}/identidad/`,
|
|
135
135
|
params: {
|
|
136
|
-
codigoAplicacion:
|
|
136
|
+
codigoAplicacion: r
|
|
137
137
|
}
|
|
138
|
-
}),
|
|
138
|
+
}), L = {
|
|
139
139
|
primary: "#1C6CCC",
|
|
140
140
|
secondary: "#17A7FF",
|
|
141
141
|
error: "#f44336",
|
|
142
142
|
warning: "#ff9800",
|
|
143
143
|
info: "#2196f3",
|
|
144
144
|
success: "#4caf50"
|
|
145
|
-
},
|
|
145
|
+
}, hr = O({
|
|
146
146
|
name: "inicializar",
|
|
147
147
|
initialState: {
|
|
148
148
|
inicializando: !0,
|
|
149
149
|
inicializado: !1,
|
|
150
150
|
instancia: {
|
|
151
|
-
color:
|
|
151
|
+
color: L
|
|
152
152
|
},
|
|
153
153
|
error: null
|
|
154
154
|
},
|
|
155
|
-
extraReducers(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}).addCase(
|
|
159
|
-
|
|
160
|
-
...
|
|
161
|
-
abreviatura:
|
|
155
|
+
extraReducers(e) {
|
|
156
|
+
e.addCase(S.pending, (r) => {
|
|
157
|
+
r.inicializando = !0;
|
|
158
|
+
}).addCase(S.fulfilled, (r, t) => {
|
|
159
|
+
r.inicializando = !1, r.inicializado = !0, r.instancia = {
|
|
160
|
+
...t.payload,
|
|
161
|
+
abreviatura: t.payload.nombre.match(/\b([A-Z])/g).join(""),
|
|
162
162
|
color: {
|
|
163
|
-
...
|
|
164
|
-
...
|
|
163
|
+
...L,
|
|
164
|
+
...t.payload.color
|
|
165
165
|
}
|
|
166
|
-
},
|
|
167
|
-
}).addCase(
|
|
168
|
-
|
|
169
|
-
color:
|
|
170
|
-
},
|
|
166
|
+
}, r.error = null;
|
|
167
|
+
}).addCase(S.rejected, (r, t) => {
|
|
168
|
+
r.inicializando = !1, r.inicializado = !1, r.instancia = {
|
|
169
|
+
color: L
|
|
170
|
+
}, r.error = t.payload;
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
|
-
}),
|
|
173
|
+
}), S = q("inicializar", async (e) => (await pr(e.devURL, e.aplicacion)).data), Rn = (e) => e.instancia, fr = hr.reducer, mr = (e) => Ne({
|
|
174
174
|
reducer: {
|
|
175
|
-
ui:
|
|
176
|
-
aplicacion:
|
|
177
|
-
login:
|
|
178
|
-
notificaciones:
|
|
179
|
-
...
|
|
175
|
+
ui: nr,
|
|
176
|
+
aplicacion: fr,
|
|
177
|
+
login: cr,
|
|
178
|
+
notificaciones: ur,
|
|
179
|
+
...e
|
|
180
180
|
}
|
|
181
|
-
}),
|
|
182
|
-
const [
|
|
183
|
-
|
|
184
|
-
|
|
181
|
+
}), gr = () => {
|
|
182
|
+
const [e, r] = Fe(!1), t = m(), a = j(), n = u((s) => s.notificaciones[0]);
|
|
183
|
+
v(() => {
|
|
184
|
+
r(!!n);
|
|
185
185
|
}, [n]);
|
|
186
186
|
const c = () => {
|
|
187
|
-
|
|
187
|
+
r(!1), t(dr());
|
|
188
188
|
};
|
|
189
|
-
return /* @__PURE__ */
|
|
190
|
-
|
|
189
|
+
return /* @__PURE__ */ o(
|
|
190
|
+
Te,
|
|
191
191
|
{
|
|
192
|
-
open:
|
|
192
|
+
open: e,
|
|
193
193
|
message: (n == null ? void 0 : n.mensaje) && n.tipo === "default" && a(n.mensaje),
|
|
194
194
|
autoHideDuration: 5e3,
|
|
195
195
|
onClose: c,
|
|
196
|
-
children: (n == null ? void 0 : n.mensaje) && n.tipo !== "default" && /* @__PURE__ */
|
|
196
|
+
children: (n == null ? void 0 : n.mensaje) && n.tipo !== "default" && /* @__PURE__ */ o(Q, { severity: n.tipo, children: a(n.mensaje) })
|
|
197
197
|
}
|
|
198
198
|
);
|
|
199
|
-
},
|
|
199
|
+
}, vr = {
|
|
200
200
|
inicializar: {
|
|
201
201
|
error: {
|
|
202
202
|
titulo: "Error iniciando aplicación",
|
|
@@ -215,158 +215,158 @@ const _ = k({
|
|
|
215
215
|
error: "Usuario o contraseña incorrectos"
|
|
216
216
|
},
|
|
217
217
|
copy: "Todos los derechos reservados "
|
|
218
|
-
},
|
|
219
|
-
es:
|
|
220
|
-
},
|
|
221
|
-
const
|
|
222
|
-
return /* @__PURE__ */
|
|
218
|
+
}, yr = {
|
|
219
|
+
es: vr
|
|
220
|
+
}, _r = { en: Ee, es: He }, oe = ({ messages: e, children: r }) => {
|
|
221
|
+
const t = u((a) => a.ui.idioma);
|
|
222
|
+
return /* @__PURE__ */ o(Le, { locale: t, messages: e[t], children: /* @__PURE__ */ o(Ue, { dateAdapter: Be, adapterLocale: _r[t], children: r }) });
|
|
223
223
|
};
|
|
224
|
-
|
|
225
|
-
messages:
|
|
226
|
-
children:
|
|
224
|
+
oe.propTypes = {
|
|
225
|
+
messages: i.object,
|
|
226
|
+
children: i.element.isRequired
|
|
227
227
|
};
|
|
228
|
-
const
|
|
229
|
-
const
|
|
230
|
-
if (!(
|
|
228
|
+
const br = () => {
|
|
229
|
+
const e = Ve();
|
|
230
|
+
if (!(e != null && e.length))
|
|
231
231
|
return;
|
|
232
|
-
const
|
|
233
|
-
return
|
|
234
|
-
},
|
|
235
|
-
const a =
|
|
236
|
-
|
|
237
|
-
let s = Reflect.ownKeys(
|
|
238
|
-
n && Object.hasOwn(
|
|
239
|
-
}, [a,
|
|
232
|
+
const r = e[0];
|
|
233
|
+
return r.indexOf("-") ? r.substring(0, r.indexOf("-")) : r;
|
|
234
|
+
}, ie = ({ messages: e, idiomaDefecto: r, children: t }) => {
|
|
235
|
+
const a = m(), n = br();
|
|
236
|
+
v(() => {
|
|
237
|
+
let s = Reflect.ownKeys(e)[0];
|
|
238
|
+
n && Object.hasOwn(e, n) ? s = n : r && Object.hasOwn(e, r) && (s = r), a(ar(s));
|
|
239
|
+
}, [a, e, r, n]);
|
|
240
240
|
const c = {};
|
|
241
|
-
return Object.keys(
|
|
241
|
+
return Object.keys(e).forEach((s) => {
|
|
242
242
|
c[s] = {
|
|
243
|
-
...
|
|
244
|
-
saas:
|
|
243
|
+
...e[s],
|
|
244
|
+
saas: yr[s]
|
|
245
245
|
};
|
|
246
|
-
}), /* @__PURE__ */
|
|
246
|
+
}), /* @__PURE__ */ o(oe, { messages: c, children: t });
|
|
247
247
|
};
|
|
248
|
-
|
|
249
|
-
messages:
|
|
250
|
-
idiomaDefecto:
|
|
251
|
-
children:
|
|
248
|
+
ie.propTypes = {
|
|
249
|
+
messages: i.object,
|
|
250
|
+
idiomaDefecto: i.string,
|
|
251
|
+
children: i.element.isRequired
|
|
252
252
|
};
|
|
253
|
-
const
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}, [
|
|
258
|
-
const c =
|
|
253
|
+
const se = ({ children: e }) => {
|
|
254
|
+
const r = m(), { instancia: t } = u((s) => s.aplicacion), a = u((s) => s.ui.tema), n = we("(prefers-color-scheme: dark)");
|
|
255
|
+
v(() => {
|
|
256
|
+
r(tr(n ? "dark" : "light"));
|
|
257
|
+
}, [r, n]);
|
|
258
|
+
const c = Me(() => Ke({
|
|
259
259
|
palette: {
|
|
260
260
|
mode: a,
|
|
261
261
|
primary: {
|
|
262
|
-
main:
|
|
262
|
+
main: t.color.primary
|
|
263
263
|
},
|
|
264
264
|
secondary: {
|
|
265
|
-
main:
|
|
265
|
+
main: t.color.secondary
|
|
266
266
|
},
|
|
267
267
|
error: {
|
|
268
|
-
main:
|
|
268
|
+
main: t.color.error
|
|
269
269
|
},
|
|
270
270
|
warning: {
|
|
271
|
-
main:
|
|
271
|
+
main: t.color.warning
|
|
272
272
|
},
|
|
273
273
|
info: {
|
|
274
|
-
main:
|
|
274
|
+
main: t.color.info
|
|
275
275
|
},
|
|
276
276
|
success: {
|
|
277
|
-
main:
|
|
277
|
+
main: t.color.success
|
|
278
278
|
},
|
|
279
279
|
...a === "light" && {
|
|
280
280
|
background: {
|
|
281
|
-
default:
|
|
282
|
-
paper:
|
|
281
|
+
default: E.A200,
|
|
282
|
+
paper: E[100]
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
},
|
|
286
286
|
shape: {
|
|
287
287
|
borderRadius: 6
|
|
288
288
|
}
|
|
289
|
-
}), [a,
|
|
290
|
-
return /* @__PURE__ */ d(
|
|
291
|
-
/* @__PURE__ */
|
|
292
|
-
|
|
289
|
+
}), [a, t]);
|
|
290
|
+
return /* @__PURE__ */ d(Je, { theme: c, children: [
|
|
291
|
+
/* @__PURE__ */ o(Se, {}),
|
|
292
|
+
e
|
|
293
293
|
] });
|
|
294
294
|
};
|
|
295
|
-
|
|
296
|
-
children:
|
|
295
|
+
se.propTypes = {
|
|
296
|
+
children: i.element.isRequired
|
|
297
297
|
};
|
|
298
|
-
const
|
|
299
|
-
const
|
|
300
|
-
return
|
|
301
|
-
|
|
302
|
-
}, [
|
|
303
|
-
},
|
|
304
|
-
const
|
|
305
|
-
return
|
|
306
|
-
|
|
307
|
-
}, [
|
|
308
|
-
},
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
devURL:
|
|
298
|
+
const ce = (e) => {
|
|
299
|
+
const r = m(), t = u((n) => n.login), a = u((n) => n.aplicacion.instancia);
|
|
300
|
+
return v(() => {
|
|
301
|
+
t.autenticado && t.expiracion && new Date(t.expiracion) < /* @__PURE__ */ new Date() && (t.refreshToken ? r(w(e, a.clientCredentials, t.refreshToken)) : r(sr()));
|
|
302
|
+
}, [e, a.clientCredentials, t, r]), t.autenticado;
|
|
303
|
+
}, Cr = () => {
|
|
304
|
+
const e = m();
|
|
305
|
+
return Ge((r, t = "default") => {
|
|
306
|
+
e(lr({ mensaje: r, tipo: t }));
|
|
307
|
+
}, [e]);
|
|
308
|
+
}, le = ({ devURL: e }) => {
|
|
309
|
+
const r = m(), t = j(), a = Cr(), { cargando: n, error: c } = u((l) => l.login), s = u((l) => l.aplicacion.instancia), D = (l) => {
|
|
310
|
+
r(T({
|
|
311
|
+
devURL: e,
|
|
312
312
|
clientCredentials: s.clientCredentials,
|
|
313
313
|
data: {
|
|
314
314
|
correo: l.correo,
|
|
315
315
|
password: l.password
|
|
316
316
|
}
|
|
317
317
|
}));
|
|
318
|
-
},
|
|
319
|
-
const
|
|
320
|
-
return l.correo || (
|
|
318
|
+
}, Ce = (l) => {
|
|
319
|
+
const I = { correo: void 0, password: void 0 };
|
|
320
|
+
return l.correo || (I.correo = t("saas.login.validacion.correo")), l.password || (I.password = t("saas.login.validacion.password")), I;
|
|
321
321
|
};
|
|
322
|
-
return
|
|
322
|
+
return v(() => {
|
|
323
323
|
c && a("saas.login.error", "error");
|
|
324
|
-
}, [a, c]), /* @__PURE__ */
|
|
325
|
-
|
|
324
|
+
}, [a, c]), /* @__PURE__ */ o(
|
|
325
|
+
Ye,
|
|
326
326
|
{
|
|
327
|
-
onSubmit:
|
|
328
|
-
validate:
|
|
327
|
+
onSubmit: D,
|
|
328
|
+
validate: Ce,
|
|
329
329
|
render: ({ handleSubmit: l }) => /* @__PURE__ */ d("form", { onSubmit: l, children: [
|
|
330
|
-
/* @__PURE__ */
|
|
331
|
-
|
|
330
|
+
/* @__PURE__ */ o(
|
|
331
|
+
U,
|
|
332
332
|
{
|
|
333
333
|
id: "correo",
|
|
334
334
|
name: "correo",
|
|
335
|
-
label:
|
|
335
|
+
label: t("saas.login.correo"),
|
|
336
336
|
variant: "outlined",
|
|
337
337
|
autoComplete: "off",
|
|
338
338
|
disabled: n,
|
|
339
339
|
autoFocus: !0,
|
|
340
340
|
InputProps: {
|
|
341
|
-
startAdornment: /* @__PURE__ */
|
|
341
|
+
startAdornment: /* @__PURE__ */ o(G, { position: "start", children: /* @__PURE__ */ o(Xe, { color: "primary" }) })
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
),
|
|
345
|
-
/* @__PURE__ */
|
|
346
|
-
|
|
345
|
+
/* @__PURE__ */ o(
|
|
346
|
+
U,
|
|
347
347
|
{
|
|
348
348
|
id: "password",
|
|
349
349
|
name: "password",
|
|
350
350
|
type: "password",
|
|
351
|
-
label:
|
|
351
|
+
label: t("saas.login.password"),
|
|
352
352
|
variant: "outlined",
|
|
353
353
|
autoComplete: "current-password",
|
|
354
354
|
disabled: n,
|
|
355
355
|
InputProps: {
|
|
356
|
-
startAdornment: /* @__PURE__ */
|
|
356
|
+
startAdornment: /* @__PURE__ */ o(G, { position: "start", children: /* @__PURE__ */ o(Qe, { color: "primary" }) })
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
359
|
),
|
|
360
|
-
/* @__PURE__ */ d(
|
|
361
|
-
/* @__PURE__ */
|
|
362
|
-
/* @__PURE__ */
|
|
363
|
-
|
|
360
|
+
/* @__PURE__ */ d(g, { container: !0, children: [
|
|
361
|
+
/* @__PURE__ */ o(g, { item: !0, xs: 6 }),
|
|
362
|
+
/* @__PURE__ */ o(g, { item: !0, xs: 6, align: "right", children: /* @__PURE__ */ o(
|
|
363
|
+
Ae,
|
|
364
364
|
{
|
|
365
365
|
variant: "contained",
|
|
366
366
|
color: "primary",
|
|
367
367
|
type: "submit",
|
|
368
368
|
disabled: n,
|
|
369
|
-
children: n ? /* @__PURE__ */
|
|
369
|
+
children: n ? /* @__PURE__ */ o(X, { size: 24, thickness: 4 }) : t("saas.login.ingresar")
|
|
370
370
|
}
|
|
371
371
|
) })
|
|
372
372
|
] })
|
|
@@ -374,12 +374,12 @@ const G = (r) => {
|
|
|
374
374
|
}
|
|
375
375
|
);
|
|
376
376
|
};
|
|
377
|
-
|
|
378
|
-
devURL:
|
|
377
|
+
le.propTypes = {
|
|
378
|
+
devURL: i.string
|
|
379
379
|
};
|
|
380
|
-
const
|
|
381
|
-
const
|
|
382
|
-
return !
|
|
380
|
+
const de = ({ devURL: e }) => {
|
|
381
|
+
const r = u((s) => s.aplicacion.instancia), t = j(), a = Y(), n = ce(e), { from: c } = a.state || { from: { pathname: "/" } };
|
|
382
|
+
return !r.requiereLogin || n ? /* @__PURE__ */ o(ee, { to: c }) : /* @__PURE__ */ d($, { sx: {
|
|
383
383
|
position: "relative",
|
|
384
384
|
display: "flex",
|
|
385
385
|
flexDirection: "column",
|
|
@@ -388,7 +388,7 @@ const M = ({ devURL: r }) => {
|
|
|
388
388
|
backgroundColor: "primary.main",
|
|
389
389
|
"&::before": {
|
|
390
390
|
content: '""',
|
|
391
|
-
backgroundImage: `url(${
|
|
391
|
+
backgroundImage: `url(${r.logo})`,
|
|
392
392
|
backgroundSize: "contain",
|
|
393
393
|
backgroundRepeat: "no-repeat",
|
|
394
394
|
backgroundPosition: "right",
|
|
@@ -401,140 +401,401 @@ const M = ({ devURL: r }) => {
|
|
|
401
401
|
filter: "grayscale(100%)"
|
|
402
402
|
}
|
|
403
403
|
}, children: [
|
|
404
|
-
/* @__PURE__ */
|
|
404
|
+
/* @__PURE__ */ o($, { sx: {
|
|
405
405
|
display: "flex",
|
|
406
406
|
justifyContent: "center",
|
|
407
407
|
alignItems: "center",
|
|
408
408
|
flexGrow: 1
|
|
409
|
-
}, children: /* @__PURE__ */
|
|
410
|
-
/* @__PURE__ */ d(
|
|
411
|
-
/* @__PURE__ */
|
|
412
|
-
/* @__PURE__ */
|
|
413
|
-
/* @__PURE__ */
|
|
409
|
+
}, children: /* @__PURE__ */ o(je, { maxWidth: "md", children: /* @__PURE__ */ d(g, { container: !0, spacing: 3, children: [
|
|
410
|
+
/* @__PURE__ */ d(g, { item: !0, xs: 12, lg: 5, align: "center", children: [
|
|
411
|
+
/* @__PURE__ */ o("img", { src: r.logo, alt: r.nombre, style: { maxWidth: "100%" } }),
|
|
412
|
+
/* @__PURE__ */ o(A, { variant: "h3", align: "center", children: t("aplicacion.nombre", { smart_count: 1 }) }),
|
|
413
|
+
/* @__PURE__ */ o(A, { variant: "h5", align: "center", children: r.nombre })
|
|
414
414
|
] }),
|
|
415
|
-
/* @__PURE__ */
|
|
415
|
+
/* @__PURE__ */ o(g, { item: !0, xs: 12, lg: 7, sx: {
|
|
416
416
|
display: "flex",
|
|
417
417
|
alignItems: "center",
|
|
418
418
|
justifyContent: "center",
|
|
419
419
|
zIndex: 5
|
|
420
|
-
}, children: /* @__PURE__ */ d(
|
|
421
|
-
/* @__PURE__ */
|
|
422
|
-
/* @__PURE__ */
|
|
420
|
+
}, children: /* @__PURE__ */ d(Oe, { elevation: 5, children: [
|
|
421
|
+
/* @__PURE__ */ o(Re, { title: t("saas.login.titulo"), titleTypographyProps: { align: "center" } }),
|
|
422
|
+
/* @__PURE__ */ o(ke, { sx: {
|
|
423
423
|
"& .MuiTextField-root": {
|
|
424
424
|
mb: 2
|
|
425
425
|
}
|
|
426
|
-
}, children: /* @__PURE__ */
|
|
426
|
+
}, children: /* @__PURE__ */ o(le, { devURL: e }) })
|
|
427
427
|
] }) })
|
|
428
428
|
] }) }) }),
|
|
429
|
-
/* @__PURE__ */
|
|
430
|
-
|
|
431
|
-
/* @__PURE__ */
|
|
429
|
+
/* @__PURE__ */ o(ze, { position: "static", color: "primary", children: /* @__PURE__ */ o(De, { sx: { justifyContent: "center" }, children: /* @__PURE__ */ d(A, { variant: "caption", children: [
|
|
430
|
+
t("saas.copy"),
|
|
431
|
+
/* @__PURE__ */ o(Ie, { href: "//chimera.com.pe", color: "inherit", target: "_blank", rel: "noreferrer", children: "Chimera Software" })
|
|
432
432
|
] }) }) })
|
|
433
433
|
] });
|
|
434
434
|
};
|
|
435
|
-
|
|
436
|
-
devURL:
|
|
435
|
+
de.propTypes = {
|
|
436
|
+
devURL: i.string
|
|
437
437
|
};
|
|
438
|
-
const
|
|
439
|
-
const a =
|
|
440
|
-
return
|
|
438
|
+
const ue = ({ devURL: e, redirectTo: r, children: t }) => {
|
|
439
|
+
const a = Y();
|
|
440
|
+
return ce(e) ? t : /* @__PURE__ */ o(ee, { to: r, state: { from: a }, replace: !0 });
|
|
441
441
|
};
|
|
442
|
-
|
|
443
|
-
devURL:
|
|
444
|
-
redirectTo:
|
|
445
|
-
children:
|
|
442
|
+
ue.propTypes = {
|
|
443
|
+
devURL: i.string,
|
|
444
|
+
redirectTo: i.string.isRequired,
|
|
445
|
+
children: i.element.isRequired
|
|
446
446
|
};
|
|
447
|
-
const
|
|
448
|
-
/* @__PURE__ */
|
|
449
|
-
/* @__PURE__ */
|
|
450
|
-
|
|
447
|
+
const pe = ({ devURL: e, requiereLogin: r, children: t }) => /* @__PURE__ */ o(Ze, { children: /* @__PURE__ */ d(We, { children: [
|
|
448
|
+
/* @__PURE__ */ o(H, { path: "/login", element: /* @__PURE__ */ o(de, { devURL: e }) }),
|
|
449
|
+
/* @__PURE__ */ o(
|
|
450
|
+
H,
|
|
451
451
|
{
|
|
452
452
|
path: "/*",
|
|
453
|
-
element:
|
|
453
|
+
element: r ? /* @__PURE__ */ o(ue, { devURL: e, redirectTo: "/login", children: t }) : t
|
|
454
454
|
}
|
|
455
455
|
)
|
|
456
456
|
] }) });
|
|
457
|
-
|
|
458
|
-
devURL:
|
|
459
|
-
requiereLogin:
|
|
460
|
-
children:
|
|
457
|
+
pe.propTypes = {
|
|
458
|
+
devURL: i.string,
|
|
459
|
+
requiereLogin: i.bool,
|
|
460
|
+
children: i.element.isRequired
|
|
461
461
|
};
|
|
462
|
-
const
|
|
463
|
-
const
|
|
464
|
-
return /* @__PURE__ */
|
|
462
|
+
const he = ({ devURL: e, children: r }) => {
|
|
463
|
+
const t = u((a) => a.aplicacion);
|
|
464
|
+
return /* @__PURE__ */ o($, { sx: {
|
|
465
465
|
display: "flex",
|
|
466
466
|
flexDirection: "column",
|
|
467
467
|
minHeight: "100vh",
|
|
468
468
|
justifyContent: "flex-start",
|
|
469
469
|
backgroundColor: "background.default"
|
|
470
|
-
}, children:
|
|
471
|
-
/* @__PURE__ */
|
|
472
|
-
/* @__PURE__ */
|
|
470
|
+
}, children: t.inicializando ? /* @__PURE__ */ o(er, {}) : t.error || !t.inicializado ? /* @__PURE__ */ o(rr, { titulo: "saas.inicializar.error.titulo", texto: "saas.inicializar.error.mensaje" }) : /* @__PURE__ */ d($e, { children: [
|
|
471
|
+
/* @__PURE__ */ o(pe, { devURL: e, requiereLogin: t.instancia.requiereLogin, children: r }),
|
|
472
|
+
/* @__PURE__ */ o(gr, {})
|
|
473
473
|
] }) });
|
|
474
474
|
};
|
|
475
|
-
|
|
476
|
-
devURL:
|
|
477
|
-
children:
|
|
475
|
+
he.propTypes = {
|
|
476
|
+
devURL: i.string,
|
|
477
|
+
children: i.element.isRequired
|
|
478
478
|
};
|
|
479
|
-
const
|
|
480
|
-
aplicacion:
|
|
481
|
-
devSaasURL:
|
|
482
|
-
devAuthURL:
|
|
479
|
+
const fe = ({
|
|
480
|
+
aplicacion: e,
|
|
481
|
+
devSaasURL: r,
|
|
482
|
+
devAuthURL: t,
|
|
483
483
|
messages: a,
|
|
484
484
|
idiomaDefecto: n,
|
|
485
485
|
children: c
|
|
486
486
|
}) => {
|
|
487
|
-
const s =
|
|
488
|
-
return
|
|
489
|
-
s(
|
|
490
|
-
}, [s,
|
|
487
|
+
const s = m();
|
|
488
|
+
return v(() => {
|
|
489
|
+
s(S({ devURL: r, aplicacion: e }));
|
|
490
|
+
}, [s, e, r]), /* @__PURE__ */ o(ie, { messages: a, idiomaDefecto: n, children: /* @__PURE__ */ o(se, { children: /* @__PURE__ */ o(he, { devURL: t, children: c }) }) });
|
|
491
491
|
};
|
|
492
|
-
|
|
493
|
-
aplicacion:
|
|
494
|
-
devSaasURL:
|
|
495
|
-
devAuthURL:
|
|
496
|
-
messages:
|
|
497
|
-
idiomaDefecto:
|
|
498
|
-
children:
|
|
492
|
+
fe.propTypes = {
|
|
493
|
+
aplicacion: i.string.isRequired,
|
|
494
|
+
devSaasURL: i.string,
|
|
495
|
+
devAuthURL: i.string,
|
|
496
|
+
messages: i.object.isRequired,
|
|
497
|
+
idiomaDefecto: i.string,
|
|
498
|
+
children: i.element.isRequired
|
|
499
499
|
};
|
|
500
|
-
const
|
|
501
|
-
customReducers:
|
|
502
|
-
aplicacion:
|
|
503
|
-
devSaasURL:
|
|
500
|
+
const $r = ({
|
|
501
|
+
customReducers: e,
|
|
502
|
+
aplicacion: r,
|
|
503
|
+
devSaasURL: t,
|
|
504
504
|
devAuthURL: a,
|
|
505
505
|
dev: n = !1,
|
|
506
506
|
idiomaDefecto: c,
|
|
507
507
|
messages: s,
|
|
508
|
-
children:
|
|
509
|
-
}) => /* @__PURE__ */
|
|
510
|
-
|
|
508
|
+
children: D
|
|
509
|
+
}) => /* @__PURE__ */ o(Pe, { store: mr(e), children: /* @__PURE__ */ o(
|
|
510
|
+
fe,
|
|
511
511
|
{
|
|
512
|
-
aplicacion:
|
|
513
|
-
devSaasURL: n ?
|
|
512
|
+
aplicacion: r,
|
|
513
|
+
devSaasURL: n ? t : void 0,
|
|
514
514
|
devAuthURL: n ? a : void 0,
|
|
515
515
|
idiomaDefecto: c,
|
|
516
516
|
messages: s,
|
|
517
|
-
children:
|
|
517
|
+
children: D
|
|
518
518
|
}
|
|
519
519
|
) });
|
|
520
|
-
|
|
521
|
-
customReducers:
|
|
522
|
-
aplicacion:
|
|
523
|
-
devSaasURL:
|
|
524
|
-
devAuthURL:
|
|
525
|
-
dev:
|
|
526
|
-
idiomaDefecto:
|
|
527
|
-
messages:
|
|
528
|
-
children:
|
|
520
|
+
$r.propTypes = {
|
|
521
|
+
customReducers: i.object,
|
|
522
|
+
aplicacion: i.string.isRequired,
|
|
523
|
+
devSaasURL: i.string,
|
|
524
|
+
devAuthURL: i.string,
|
|
525
|
+
dev: i.bool,
|
|
526
|
+
idiomaDefecto: i.string,
|
|
527
|
+
messages: i.object,
|
|
528
|
+
children: i.element.isRequired
|
|
529
529
|
};
|
|
530
|
+
var x = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
531
|
+
function xr(e) {
|
|
532
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
533
|
+
}
|
|
534
|
+
var Tr = typeof x == "object" && x && x.Object === Object && x, wr = Tr, Sr = wr, jr = typeof self == "object" && self && self.Object === Object && self, Or = Sr || jr || Function("return this")(), F = Or, Rr = F, kr = Rr.Symbol, me = kr, B = me, ge = Object.prototype, zr = ge.hasOwnProperty, Dr = ge.toString, C = B ? B.toStringTag : void 0;
|
|
535
|
+
function Ir(e) {
|
|
536
|
+
var r = zr.call(e, C), t = e[C];
|
|
537
|
+
try {
|
|
538
|
+
e[C] = void 0;
|
|
539
|
+
var a = !0;
|
|
540
|
+
} catch {
|
|
541
|
+
}
|
|
542
|
+
var n = Dr.call(e);
|
|
543
|
+
return a && (r ? e[C] = t : delete e[C]), n;
|
|
544
|
+
}
|
|
545
|
+
var Ar = Ir, Lr = Object.prototype, Pr = Lr.toString;
|
|
546
|
+
function Nr(e) {
|
|
547
|
+
return Pr.call(e);
|
|
548
|
+
}
|
|
549
|
+
var qr = Nr, V = me, Fr = Ar, Mr = qr, Gr = "[object Null]", Er = "[object Undefined]", K = V ? V.toStringTag : void 0;
|
|
550
|
+
function Hr(e) {
|
|
551
|
+
return e == null ? e === void 0 ? Er : Gr : K && K in Object(e) ? Fr(e) : Mr(e);
|
|
552
|
+
}
|
|
553
|
+
var Ur = Hr;
|
|
554
|
+
function Br(e) {
|
|
555
|
+
var r = typeof e;
|
|
556
|
+
return e != null && (r == "object" || r == "function");
|
|
557
|
+
}
|
|
558
|
+
var ve = Br, Vr = Ur, Kr = ve, Jr = "[object AsyncFunction]", Zr = "[object Function]", Wr = "[object GeneratorFunction]", Xr = "[object Proxy]";
|
|
559
|
+
function Qr(e) {
|
|
560
|
+
if (!Kr(e))
|
|
561
|
+
return !1;
|
|
562
|
+
var r = Vr(e);
|
|
563
|
+
return r == Zr || r == Wr || r == Jr || r == Xr;
|
|
564
|
+
}
|
|
565
|
+
var Yr = Qr, et = F, rt = et["__core-js_shared__"], tt = rt, P = tt, J = function() {
|
|
566
|
+
var e = /[^.]+$/.exec(P && P.keys && P.keys.IE_PROTO || "");
|
|
567
|
+
return e ? "Symbol(src)_1." + e : "";
|
|
568
|
+
}();
|
|
569
|
+
function at(e) {
|
|
570
|
+
return !!J && J in e;
|
|
571
|
+
}
|
|
572
|
+
var nt = at, ot = Function.prototype, it = ot.toString;
|
|
573
|
+
function st(e) {
|
|
574
|
+
if (e != null) {
|
|
575
|
+
try {
|
|
576
|
+
return it.call(e);
|
|
577
|
+
} catch {
|
|
578
|
+
}
|
|
579
|
+
try {
|
|
580
|
+
return e + "";
|
|
581
|
+
} catch {
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
return "";
|
|
585
|
+
}
|
|
586
|
+
var ct = st, lt = Yr, dt = nt, ut = ve, pt = ct, ht = /[\\^$.*+?()[\]{}|]/g, ft = /^\[object .+?Constructor\]$/, mt = Function.prototype, gt = Object.prototype, vt = mt.toString, yt = gt.hasOwnProperty, _t = RegExp(
|
|
587
|
+
"^" + vt.call(yt).replace(ht, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
588
|
+
);
|
|
589
|
+
function bt(e) {
|
|
590
|
+
if (!ut(e) || dt(e))
|
|
591
|
+
return !1;
|
|
592
|
+
var r = lt(e) ? _t : ft;
|
|
593
|
+
return r.test(pt(e));
|
|
594
|
+
}
|
|
595
|
+
var Ct = bt;
|
|
596
|
+
function $t(e, r) {
|
|
597
|
+
return e == null ? void 0 : e[r];
|
|
598
|
+
}
|
|
599
|
+
var xt = $t, Tt = Ct, wt = xt;
|
|
600
|
+
function St(e, r) {
|
|
601
|
+
var t = wt(e, r);
|
|
602
|
+
return Tt(t) ? t : void 0;
|
|
603
|
+
}
|
|
604
|
+
var ye = St, jt = ye, Ot = jt(Object, "create"), R = Ot, Z = R;
|
|
605
|
+
function Rt() {
|
|
606
|
+
this.__data__ = Z ? Z(null) : {}, this.size = 0;
|
|
607
|
+
}
|
|
608
|
+
var kt = Rt;
|
|
609
|
+
function zt(e) {
|
|
610
|
+
var r = this.has(e) && delete this.__data__[e];
|
|
611
|
+
return this.size -= r ? 1 : 0, r;
|
|
612
|
+
}
|
|
613
|
+
var Dt = zt, It = R, At = "__lodash_hash_undefined__", Lt = Object.prototype, Pt = Lt.hasOwnProperty;
|
|
614
|
+
function Nt(e) {
|
|
615
|
+
var r = this.__data__;
|
|
616
|
+
if (It) {
|
|
617
|
+
var t = r[e];
|
|
618
|
+
return t === At ? void 0 : t;
|
|
619
|
+
}
|
|
620
|
+
return Pt.call(r, e) ? r[e] : void 0;
|
|
621
|
+
}
|
|
622
|
+
var qt = Nt, Ft = R, Mt = Object.prototype, Gt = Mt.hasOwnProperty;
|
|
623
|
+
function Et(e) {
|
|
624
|
+
var r = this.__data__;
|
|
625
|
+
return Ft ? r[e] !== void 0 : Gt.call(r, e);
|
|
626
|
+
}
|
|
627
|
+
var Ht = Et, Ut = R, Bt = "__lodash_hash_undefined__";
|
|
628
|
+
function Vt(e, r) {
|
|
629
|
+
var t = this.__data__;
|
|
630
|
+
return this.size += this.has(e) ? 0 : 1, t[e] = Ut && r === void 0 ? Bt : r, this;
|
|
631
|
+
}
|
|
632
|
+
var Kt = Vt, Jt = kt, Zt = Dt, Wt = qt, Xt = Ht, Qt = Kt;
|
|
633
|
+
function y(e) {
|
|
634
|
+
var r = -1, t = e == null ? 0 : e.length;
|
|
635
|
+
for (this.clear(); ++r < t; ) {
|
|
636
|
+
var a = e[r];
|
|
637
|
+
this.set(a[0], a[1]);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
y.prototype.clear = Jt;
|
|
641
|
+
y.prototype.delete = Zt;
|
|
642
|
+
y.prototype.get = Wt;
|
|
643
|
+
y.prototype.has = Xt;
|
|
644
|
+
y.prototype.set = Qt;
|
|
645
|
+
var Yt = y;
|
|
646
|
+
function ea() {
|
|
647
|
+
this.__data__ = [], this.size = 0;
|
|
648
|
+
}
|
|
649
|
+
var ra = ea;
|
|
650
|
+
function ta(e, r) {
|
|
651
|
+
return e === r || e !== e && r !== r;
|
|
652
|
+
}
|
|
653
|
+
var aa = ta, na = aa;
|
|
654
|
+
function oa(e, r) {
|
|
655
|
+
for (var t = e.length; t--; )
|
|
656
|
+
if (na(e[t][0], r))
|
|
657
|
+
return t;
|
|
658
|
+
return -1;
|
|
659
|
+
}
|
|
660
|
+
var k = oa, ia = k, sa = Array.prototype, ca = sa.splice;
|
|
661
|
+
function la(e) {
|
|
662
|
+
var r = this.__data__, t = ia(r, e);
|
|
663
|
+
if (t < 0)
|
|
664
|
+
return !1;
|
|
665
|
+
var a = r.length - 1;
|
|
666
|
+
return t == a ? r.pop() : ca.call(r, t, 1), --this.size, !0;
|
|
667
|
+
}
|
|
668
|
+
var da = la, ua = k;
|
|
669
|
+
function pa(e) {
|
|
670
|
+
var r = this.__data__, t = ua(r, e);
|
|
671
|
+
return t < 0 ? void 0 : r[t][1];
|
|
672
|
+
}
|
|
673
|
+
var ha = pa, fa = k;
|
|
674
|
+
function ma(e) {
|
|
675
|
+
return fa(this.__data__, e) > -1;
|
|
676
|
+
}
|
|
677
|
+
var ga = ma, va = k;
|
|
678
|
+
function ya(e, r) {
|
|
679
|
+
var t = this.__data__, a = va(t, e);
|
|
680
|
+
return a < 0 ? (++this.size, t.push([e, r])) : t[a][1] = r, this;
|
|
681
|
+
}
|
|
682
|
+
var _a = ya, ba = ra, Ca = da, $a = ha, xa = ga, Ta = _a;
|
|
683
|
+
function _(e) {
|
|
684
|
+
var r = -1, t = e == null ? 0 : e.length;
|
|
685
|
+
for (this.clear(); ++r < t; ) {
|
|
686
|
+
var a = e[r];
|
|
687
|
+
this.set(a[0], a[1]);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
_.prototype.clear = ba;
|
|
691
|
+
_.prototype.delete = Ca;
|
|
692
|
+
_.prototype.get = $a;
|
|
693
|
+
_.prototype.has = xa;
|
|
694
|
+
_.prototype.set = Ta;
|
|
695
|
+
var wa = _, Sa = ye, ja = F, Oa = Sa(ja, "Map"), Ra = Oa, W = Yt, ka = wa, za = Ra;
|
|
696
|
+
function Da() {
|
|
697
|
+
this.size = 0, this.__data__ = {
|
|
698
|
+
hash: new W(),
|
|
699
|
+
map: new (za || ka)(),
|
|
700
|
+
string: new W()
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
var Ia = Da;
|
|
704
|
+
function Aa(e) {
|
|
705
|
+
var r = typeof e;
|
|
706
|
+
return r == "string" || r == "number" || r == "symbol" || r == "boolean" ? e !== "__proto__" : e === null;
|
|
707
|
+
}
|
|
708
|
+
var La = Aa, Pa = La;
|
|
709
|
+
function Na(e, r) {
|
|
710
|
+
var t = e.__data__;
|
|
711
|
+
return Pa(r) ? t[typeof r == "string" ? "string" : "hash"] : t.map;
|
|
712
|
+
}
|
|
713
|
+
var z = Na, qa = z;
|
|
714
|
+
function Fa(e) {
|
|
715
|
+
var r = qa(this, e).delete(e);
|
|
716
|
+
return this.size -= r ? 1 : 0, r;
|
|
717
|
+
}
|
|
718
|
+
var Ma = Fa, Ga = z;
|
|
719
|
+
function Ea(e) {
|
|
720
|
+
return Ga(this, e).get(e);
|
|
721
|
+
}
|
|
722
|
+
var Ha = Ea, Ua = z;
|
|
723
|
+
function Ba(e) {
|
|
724
|
+
return Ua(this, e).has(e);
|
|
725
|
+
}
|
|
726
|
+
var Va = Ba, Ka = z;
|
|
727
|
+
function Ja(e, r) {
|
|
728
|
+
var t = Ka(this, e), a = t.size;
|
|
729
|
+
return t.set(e, r), this.size += t.size == a ? 0 : 1, this;
|
|
730
|
+
}
|
|
731
|
+
var Za = Ja, Wa = Ia, Xa = Ma, Qa = Ha, Ya = Va, en = Za;
|
|
732
|
+
function b(e) {
|
|
733
|
+
var r = -1, t = e == null ? 0 : e.length;
|
|
734
|
+
for (this.clear(); ++r < t; ) {
|
|
735
|
+
var a = e[r];
|
|
736
|
+
this.set(a[0], a[1]);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
b.prototype.clear = Wa;
|
|
740
|
+
b.prototype.delete = Xa;
|
|
741
|
+
b.prototype.get = Qa;
|
|
742
|
+
b.prototype.has = Ya;
|
|
743
|
+
b.prototype.set = en;
|
|
744
|
+
var rn = b, _e = rn, tn = "Expected a function";
|
|
745
|
+
function M(e, r) {
|
|
746
|
+
if (typeof e != "function" || r != null && typeof r != "function")
|
|
747
|
+
throw new TypeError(tn);
|
|
748
|
+
var t = function() {
|
|
749
|
+
var a = arguments, n = r ? r.apply(this, a) : a[0], c = t.cache;
|
|
750
|
+
if (c.has(n))
|
|
751
|
+
return c.get(n);
|
|
752
|
+
var s = e.apply(this, a);
|
|
753
|
+
return t.cache = c.set(n, s) || c, s;
|
|
754
|
+
};
|
|
755
|
+
return t.cache = new (M.Cache || _e)(), t;
|
|
756
|
+
}
|
|
757
|
+
M.Cache = _e;
|
|
758
|
+
var an = M;
|
|
759
|
+
const be = /* @__PURE__ */ xr(an), nn = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/, h = (e) => typeof e > "u" || e === null || e === "" || Array.isArray(e) && e.length === 0, p = (e, r, t, a) => typeof e == "function" ? e({ args: r, value: t, values: a }) : r ? { message: e, args: r } : e, f = (e) => be(e, (...r) => JSON.stringify(r)), kn = (...e) => (r, t, a) => (Array.isArray(e[0]) ? e[0] : e).reduce(
|
|
760
|
+
(c, s) => c || typeof s == "function" && s(r, t, a),
|
|
761
|
+
void 0
|
|
762
|
+
), zn = f((e = "validacion.obligatorio") => Object.assign(
|
|
763
|
+
(r, t) => h(r) ? p(e, void 0, r, t) : void 0,
|
|
764
|
+
{ isRequired: !0 }
|
|
765
|
+
)), Dn = f((e = "validacion.obligatorio") => Object.assign(
|
|
766
|
+
(r, t) => h(r) || !r ? p(e, void 0, r, t) : void 0,
|
|
767
|
+
{ isRequired: !0 }
|
|
768
|
+
)), In = f((e = "validacion.numero") => (r, t) => !h(r) && isNaN(r) ? p(e, void 0, r, t) : void 0), An = f(
|
|
769
|
+
(e, r = "validacion.longitud.minima") => (t, a) => !h(t) && t.length < e ? p(r, void 0, t, a) : void 0
|
|
770
|
+
), Ln = f(
|
|
771
|
+
(e, r = "validacion.longitud.maxima") => (t, a) => !h(t) && t.length > e ? p(r, void 0, t, a) : void 0
|
|
772
|
+
), Pn = f(
|
|
773
|
+
(e, r = "validacion.minimo") => (t, a) => !h(t) && parseFloat(t) < e ? p(r, void 0, t, a) : void 0
|
|
774
|
+
), Nn = f(
|
|
775
|
+
(e, r = "validacion.maximo") => (t, a) => !h(t) && parseFloat(t) > e ? p(r, void 0, t, a) : void 0
|
|
776
|
+
), on = be(
|
|
777
|
+
(e, r = "validacion.regex") => (t, a) => !h(t) && typeof t == "string" && !e.test(t) ? p(r, void 0, t, a) : void 0,
|
|
778
|
+
(e, r) => e.toString() + r
|
|
779
|
+
), qn = f((e = "validacion.correo") => on(nn, e)), Fn = f((e, r, t = "validacion.remote") => (a, n, c) => c.active && !h(a) && e(a, r).then((s) => s ? p(t, void 0, a, n) : void 0).catch((s) => p(s.message, void 0, a, n)));
|
|
530
780
|
export {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
781
|
+
er as Cargando,
|
|
782
|
+
rr as Error,
|
|
783
|
+
$r as SaasApp,
|
|
784
|
+
kn as composeValidators,
|
|
785
|
+
qn as email,
|
|
786
|
+
Rn as getInstancia,
|
|
787
|
+
On as getPerfiles,
|
|
788
|
+
Sn as getToken,
|
|
789
|
+
jn as getUsuario,
|
|
790
|
+
sr as logout,
|
|
791
|
+
Nn as max,
|
|
792
|
+
Ln as maxLength,
|
|
793
|
+
Pn as min,
|
|
794
|
+
An as minLength,
|
|
795
|
+
In as number,
|
|
796
|
+
on as regex,
|
|
797
|
+
Fn as remote,
|
|
798
|
+
zn as required,
|
|
799
|
+
Dn as requiredNotFalse,
|
|
800
|
+
Cr as useNotificar
|
|
540
801
|
};
|
package/dist/react-saas.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(c,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react/jsx-runtime"),require("@mui/material"),require("react-polyglot"),require("prop-types"),require("react-redux"),require("@reduxjs/toolkit"),require("axios"),require("jwt-decode"),require("react"),require("date-fns/locale"),require("@mui/x-date-pickers"),require("@mui/x-date-pickers/AdapterDateFns"),require("navigator-languages"),require("@mui/material/styles"),require("@mui/material/colors"),require("react-router-dom"),require("@mui/icons-material"),require("react-final-form"),require("mui-rff")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@mui/material","react-polyglot","prop-types","react-redux","@reduxjs/toolkit","axios","jwt-decode","react","date-fns/locale","@mui/x-date-pickers","@mui/x-date-pickers/AdapterDateFns","navigator-languages","@mui/material/styles","@mui/material/colors","react-router-dom","@mui/icons-material","react-final-form","mui-rff"],n):(c=typeof globalThis<"u"?globalThis:c||self,n(c["react-saas"]={},c.ReactJSX,c.MuiMaterial,c.ReactPolyglot,c.PropTypes,c.ReactRedux,c.ReduxToolkit,c.Axios,c.JWTDecode,c.React,c.DateFNSLocale,c.MuiXDatePickers,c.MuiXDatePickersAdapter,c.NavigatorLanguages,c.MuiMaterialStyles,c.MuiMaterialColors,c.ReactRouterDom,c.MuiIconsMaterial,c.ReactFinalForm,c.MUIRFF))})(this,function(c,n,t,m,s,u,g,x,Q,f,q,Z,V,Y,b,A,h,j,P,L){"use strict";const T=()=>n.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:"center"},children:n.jsx(t.CircularProgress,{})}),z=({titulo:r,texto:e,align:i="center",severity:a="error"})=>{const o=m.useTranslate();return n.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:i},children:n.jsxs(t.Alert,{severity:a,children:[n.jsx(t.AlertTitle,{children:o(r)}),e&&o(e)]})})};Error.propTypes={titulo:s.string.isRequired,texto:s.string,align:s.string,severity:s.string};const I=g.createSlice({name:"ui",initialState:{tema:"light",temaSeleccionado:!1,idioma:"es"},reducers:{cambiarTema:(r,e)=>{r.tema=e.payload,r.temaSeleccionado=!0,localStorage.setItem("tema",e.payload)},cambiarIdioma:(r,e)=>{r.idioma=e.payload}}}),{cambiarTema:R,cambiarIdioma:ee}=I.actions,re=I.reducer,ie="https://saas.chimera.com.pe/backend",ne="https://saas.chimera.com.pe/oauth",D=(r=ne)=>({login:(e,i)=>x({url:`${r}/oauth/token`,headers:{"content-type":"application/x-www-form-urlencoded",Authorization:`Basic ${e}`},method:"post",data:{username:i.correo,password:i.password,grant_type:"password"}}),refreshToken:(e,i)=>x({url:`${r}/oauth/token`,headers:{"content-type":"application/x-www-form-urlencoded",Authorization:`Basic ${e}`},method:"post",data:{refresh_token:i,grant_type:"refresh_token"}})}),F=g.createSlice({name:"login",initialState:{cargando:!1,autenticado:!1,token:null,refreshToken:null,expiracion:null,usuario:null,perfiles:[],error:null},reducers:{logout:r=>{r.cargando=!1,r.autenticado=!1,r.token=null,r.refreshToken=null,r.expiracion=null,r.usuario=null,r.perfiles=[],r.error=null}},extraReducers(r){r.addCase(k.pending,e=>{e.cargando=!0,e.error=null}).addCase(k.fulfilled,(e,i)=>{const a=i.payload.access_token,o=Q(a),d=new Date;d.setSeconds(d.getSeconds()+i.payload.expires_in),e.cargando=!1,e.autenticado=!0,e.token=a,e.refreshToken=i.payload.refresh_token,e.expiracion=d.getTime(),e.usuario=o.name,e.perfiles=o.authorities}).addCase(k.rejected,(e,i)=>{var a;console.log(i),e.cargando=!1,e.autenticado=!1,e.token=null,e.refreshToken=null,e.expiracion=null,e.usuario=null,e.perfiles=[],e.error=(a=i.error)==null?void 0:a.message}).addCase(y.pending,e=>{e.cargando=!0}).addCase(y.fulfilled,(e,i)=>{const a=new Date;a.setSeconds(a.getSeconds()+i.payload.expires_in),e.token=i.payload.access_token,e.refreshToken=i.payload.refresh_token,e.expiracion=a.getTime()}).addCase(y.rejected,(e,i)=>{var a;e.cargando=!1,e.autenticado=!1,e.token=null,e.refreshToken=null,e.expiracion=null,e.usuario=null,e.perfiles=[],e.error=(a=i.error)==null?void 0:a.message})}}),k=g.createAsyncThunk("login/requestToken",async r=>(await D(r.devURL).login(r.clientCredentials,r.data)).data),y=g.createAsyncThunk("login/refreshToken",async(r,e,i)=>(await D(r).refreshToken(e,i)).data),{logout:U}=F.actions,oe=r=>r.token,ae=r=>r.usuario,se=r=>r.perfiles,ce=F.reducer,M=g.createSlice({name:"notificacion",initialState:[],reducers:{mostrarNotificacion:(r,e)=>{r.push(e.payload)},ocultarNotificacion:r=>{r.pop()}}}),{mostrarNotificacion:te,ocultarNotificacion:le}=M.actions,de=M.reducer,ue=(r=ie,e)=>x({url:`${r}/identidad/`,params:{codigoAplicacion:e}}),C={primary:"#1C6CCC",secondary:"#17A7FF",error:"#f44336",warning:"#ff9800",info:"#2196f3",success:"#4caf50"},pe=g.createSlice({name:"inicializar",initialState:{inicializando:!0,inicializado:!1,instancia:{color:C},error:null},extraReducers(r){r.addCase(S.pending,e=>{e.inicializando=!0}).addCase(S.fulfilled,(e,i)=>{e.inicializando=!1,e.inicializado=!0,e.instancia={...i.payload,abreviatura:i.payload.nombre.match(/\b([A-Z])/g).join(""),color:{...C,...i.payload.color}},e.error=null}).addCase(S.rejected,(e,i)=>{e.inicializando=!1,e.inicializado=!1,e.instancia={color:C},e.error=i.payload})}}),S=g.createAsyncThunk("inicializar",async r=>(await ue(r.devURL,r.aplicacion)).data),fe=r=>r.instancia,ge=pe.reducer,he=r=>g.configureStore({reducer:{ui:re,aplicacion:ge,login:ce,notificaciones:de,...r}}),me=()=>{const[r,e]=f.useState(!1),i=u.useDispatch(),a=m.useTranslate(),o=u.useSelector(l=>l.notificaciones[0]);f.useEffect(()=>{e(!!o)},[o]);const d=()=>{e(!1),i(le())};return n.jsx(t.Snackbar,{open:r,message:(o==null?void 0:o.mensaje)&&o.tipo==="default"&&a(o.mensaje),autoHideDuration:5e3,onClose:d,children:(o==null?void 0:o.mensaje)&&o.tipo!=="default"&&n.jsx(t.Alert,{severity:o.tipo,children:a(o.mensaje)})})},ke={es:{inicializar:{error:{titulo:"Error iniciando aplicación",mensaje:"No fue posible conectarnos con el servicio"}},login:{titulo:"Acceder al sistema",correo:"Correo electrónico",password:"Contraseña",ingresar:"Acceder",validacion:{correo:"Debe ingresar una dirección de correo",password:"Debe ingresar una contraseña"},error:"Usuario o contraseña incorrectos"},copy:"Todos los derechos reservados "}},ye={en:q.enGB,es:q.es},N=({messages:r,children:e})=>{const i=u.useSelector(a=>a.ui.idioma);return n.jsx(m.I18n,{locale:i,messages:r[i],children:n.jsx(Z.LocalizationProvider,{dateAdapter:V.AdapterDateFns,adapterLocale:ye[i],children:e})})};N.propTypes={messages:s.object,children:s.element.isRequired};const Se=()=>{const r=Y();if(!(r!=null&&r.length))return;const e=r[0];return e.indexOf("-")?e.substring(0,e.indexOf("-")):e},B=({messages:r,idiomaDefecto:e,children:i})=>{const a=u.useDispatch(),o=Se();f.useEffect(()=>{let l=Reflect.ownKeys(r)[0];o&&Object.hasOwn(r,o)?l=o:e&&Object.hasOwn(r,e)&&(l=e),a(ee(l))},[a,r,e,o]);const d={};return Object.keys(r).forEach(l=>{d[l]={...r[l],saas:ke[l]}}),n.jsx(N,{messages:d,children:i})};B.propTypes={messages:s.object,idiomaDefecto:s.string,children:s.element.isRequired};const E=({children:r})=>{const e=u.useDispatch(),{instancia:i}=u.useSelector(l=>l.aplicacion),a=u.useSelector(l=>l.ui.tema),o=t.useMediaQuery("(prefers-color-scheme: dark)");f.useEffect(()=>{e(R(o?"dark":"light"))},[e,o]);const d=f.useMemo(()=>b.createTheme({palette:{mode:a,primary:{main:i.color.primary},secondary:{main:i.color.secondary},error:{main:i.color.error},warning:{main:i.color.warning},info:{main:i.color.info},success:{main:i.color.success},...a==="light"&&{background:{default:A.grey.A200,paper:A.grey[100]}}},shape:{borderRadius:6}}),[a,i]);return n.jsxs(b.ThemeProvider,{theme:d,children:[n.jsx(t.CssBaseline,{}),r]})};E.propTypes={children:s.element.isRequired};const _=r=>{const e=u.useDispatch(),i=u.useSelector(o=>o.login),a=u.useSelector(o=>o.aplicacion.instancia);return f.useEffect(()=>{i.autenticado&&i.expiracion&&new Date(i.expiracion)<new Date&&(i.refreshToken?e(y(r,a.clientCredentials,i.refreshToken)):e(U()))},[r,a.clientCredentials,i,e]),i.autenticado},G=()=>{const r=u.useDispatch();return f.useCallback((e,i="default")=>{r(te({mensaje:e,tipo:i}))},[r])},O=({devURL:r})=>{const e=u.useDispatch(),i=m.useTranslate(),a=G(),{cargando:o,error:d}=u.useSelector(p=>p.login),l=u.useSelector(p=>p.aplicacion.instancia),w=p=>{e(k({devURL:r,clientCredentials:l.clientCredentials,data:{correo:p.correo,password:p.password}}))},xe=p=>{const v={correo:void 0,password:void 0};return p.correo||(v.correo=i("saas.login.validacion.correo")),p.password||(v.password=i("saas.login.validacion.password")),v};return f.useEffect(()=>{d&&a("saas.login.error","error")},[a,d]),n.jsx(P.Form,{onSubmit:w,validate:xe,render:({handleSubmit:p})=>n.jsxs("form",{onSubmit:p,children:[n.jsx(L.TextField,{id:"correo",name:"correo",label:i("saas.login.correo"),variant:"outlined",autoComplete:"off",disabled:o,autoFocus:!0,InputProps:{startAdornment:n.jsx(t.InputAdornment,{position:"start",children:n.jsx(j.Email,{color:"primary"})})}}),n.jsx(L.TextField,{id:"password",name:"password",type:"password",label:i("saas.login.password"),variant:"outlined",autoComplete:"current-password",disabled:o,InputProps:{startAdornment:n.jsx(t.InputAdornment,{position:"start",children:n.jsx(j.Lock,{color:"primary"})})}}),n.jsxs(t.Grid,{container:!0,children:[n.jsx(t.Grid,{item:!0,xs:6}),n.jsx(t.Grid,{item:!0,xs:6,align:"right",children:n.jsx(t.Button,{variant:"contained",color:"primary",type:"submit",disabled:o,children:o?n.jsx(t.CircularProgress,{size:24,thickness:4}):i("saas.login.ingresar")})})]})]})})};O.propTypes={devURL:s.string};const $=({devURL:r})=>{const e=u.useSelector(l=>l.aplicacion.instancia),i=m.useTranslate(),a=h.useLocation(),o=_(r),{from:d}=a.state||{from:{pathname:"/"}};return!e.requiereLogin||o?n.jsx(h.Navigate,{to:d}):n.jsxs(t.Box,{sx:{position:"relative",display:"flex",flexDirection:"column",flexGrow:1,minHeight:"100vh",backgroundColor:"primary.main","&::before":{content:'""',backgroundImage:`url(${e.logo})`,backgroundSize:"contain",backgroundRepeat:"no-repeat",backgroundPosition:"right",position:"absolute",top:"20%",bottom:0,right:0,width:"50%",opacity:.02,filter:"grayscale(100%)"}},children:[n.jsx(t.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",flexGrow:1},children:n.jsx(t.Container,{maxWidth:"md",children:n.jsxs(t.Grid,{container:!0,spacing:3,children:[n.jsxs(t.Grid,{item:!0,xs:12,lg:5,align:"center",children:[n.jsx("img",{src:e.logo,alt:e.nombre,style:{maxWidth:"100%"}}),n.jsx(t.Typography,{variant:"h3",align:"center",children:i("aplicacion.nombre",{smart_count:1})}),n.jsx(t.Typography,{variant:"h5",align:"center",children:e.nombre})]}),n.jsx(t.Grid,{item:!0,xs:12,lg:7,sx:{display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:n.jsxs(t.Card,{elevation:5,children:[n.jsx(t.CardHeader,{title:i("saas.login.titulo"),titleTypographyProps:{align:"center"}}),n.jsx(t.CardContent,{sx:{"& .MuiTextField-root":{mb:2}},children:n.jsx(O,{devURL:r})})]})})]})})}),n.jsx(t.AppBar,{position:"static",color:"primary",children:n.jsx(t.Toolbar,{sx:{justifyContent:"center"},children:n.jsxs(t.Typography,{variant:"caption",children:[i("saas.copy"),n.jsx(t.Link,{href:"//chimera.com.pe",color:"inherit",target:"_blank",rel:"noreferrer",children:"Chimera Software"})]})})})]})};$.propTypes={devURL:s.string};const H=({devURL:r,redirectTo:e,children:i})=>{const a=h.useLocation();return _(r)?i:n.jsx(h.Navigate,{to:e,state:{from:a},replace:!0})};H.propTypes={devURL:s.string,redirectTo:s.string.isRequired,children:s.element.isRequired};const W=({devURL:r,requiereLogin:e,children:i})=>n.jsx(h.BrowserRouter,{children:n.jsxs(h.Routes,{children:[n.jsx(h.Route,{path:"/login",element:n.jsx($,{devURL:r})}),n.jsx(h.Route,{path:"/*",element:e?n.jsx(H,{devURL:r,redirectTo:"/login",children:i}):i})]})});W.propTypes={devURL:s.string,requiereLogin:s.bool,children:s.element.isRequired};const X=({devURL:r,children:e})=>{const i=u.useSelector(a=>a.aplicacion);return n.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",minHeight:"100vh",justifyContent:"flex-start",backgroundColor:"background.default"},children:i.inicializando?n.jsx(T,{}):i.error||!i.inicializado?n.jsx(z,{titulo:"saas.inicializar.error.titulo",texto:"saas.inicializar.error.mensaje"}):n.jsxs(n.Fragment,{children:[n.jsx(W,{devURL:r,requiereLogin:i.instancia.requiereLogin,children:e}),n.jsx(me,{})]})})};X.propTypes={devURL:s.string,children:s.element.isRequired};const J=({aplicacion:r,devSaasURL:e,devAuthURL:i,messages:a,idiomaDefecto:o,children:d})=>{const l=u.useDispatch();return f.useEffect(()=>{l(S({devURL:e,aplicacion:r}))},[l,r,e]),n.jsx(B,{messages:a,idiomaDefecto:o,children:n.jsx(E,{children:n.jsx(X,{devURL:i,children:d})})})};J.propTypes={aplicacion:s.string.isRequired,devSaasURL:s.string,devAuthURL:s.string,messages:s.object.isRequired,idiomaDefecto:s.string,children:s.element.isRequired};const K=({customReducers:r,aplicacion:e,devSaasURL:i,devAuthURL:a,dev:o=!1,idiomaDefecto:d,messages:l,children:w})=>n.jsx(u.Provider,{store:he(r),children:n.jsx(J,{aplicacion:e,devSaasURL:o?i:void 0,devAuthURL:o?a:void 0,idiomaDefecto:d,messages:l,children:w})});K.propTypes={customReducers:s.object,aplicacion:s.string.isRequired,devSaasURL:s.string,devAuthURL:s.string,dev:s.bool,idiomaDefecto:s.string,messages:s.object,children:s.element.isRequired},c.Cargando=T,c.Error=z,c.SaasApp=K,c.getInstancia=fe,c.getPerfiles=se,c.getToken=oe,c.getUsuario=ae,c.logout=U,c.useNotificar=G,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(o,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("react/jsx-runtime"),require("@mui/material"),require("react-polyglot"),require("prop-types"),require("react-redux"),require("@reduxjs/toolkit"),require("axios"),require("jwt-decode"),require("react"),require("date-fns/locale"),require("@mui/x-date-pickers"),require("@mui/x-date-pickers/AdapterDateFns"),require("navigator-languages"),require("@mui/material/styles"),require("@mui/material/colors"),require("react-router-dom"),require("@mui/icons-material"),require("react-final-form"),require("mui-rff")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@mui/material","react-polyglot","prop-types","react-redux","@reduxjs/toolkit","axios","jwt-decode","react","date-fns/locale","@mui/x-date-pickers","@mui/x-date-pickers/AdapterDateFns","navigator-languages","@mui/material/styles","@mui/material/colors","react-router-dom","@mui/icons-material","react-final-form","mui-rff"],t):(o=typeof globalThis<"u"?globalThis:o||self,t(o["react-saas"]={},o.ReactJSX,o.MuiMaterial,o.ReactPolyglot,o.PropTypes,o.ReactRedux,o.ReduxToolkit,o.Axios,o.JWTDecode,o.React,o.DateFNSLocale,o.MuiXDatePickers,o.MuiXDatePickersAdapter,o.NavigatorLanguages,o.MuiMaterialStyles,o.MuiMaterialColors,o.ReactRouterDom,o.MuiIconsMaterial,o.ReactFinalForm,o.MUIRFF))})(this,function(o,t,c,S,s,u,m,z,be,p,N,Se,$e,je,G,E,_,H,we,U){"use strict";const B=()=>t.jsx(c.Box,{sx:{display:"flex",flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:"center"},children:t.jsx(c.CircularProgress,{})}),V=({titulo:e,texto:r,align:a="center",severity:n="error"})=>{const i=S.useTranslate();return t.jsx(c.Box,{sx:{display:"flex",flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:a},children:t.jsxs(c.Alert,{severity:n,children:[t.jsx(c.AlertTitle,{children:i(e)}),r&&i(r)]})})};Error.propTypes={titulo:s.string.isRequired,texto:s.string,align:s.string,severity:s.string};const J=m.createSlice({name:"ui",initialState:{tema:"light",temaSeleccionado:!1,idioma:"es"},reducers:{cambiarTema:(e,r)=>{e.tema=r.payload,e.temaSeleccionado=!0,localStorage.setItem("tema",r.payload)},cambiarIdioma:(e,r)=>{e.idioma=r.payload}}}),{cambiarTema:xe,cambiarIdioma:Te}=J.actions,ke=J.reducer,Oe="https://saas.chimera.com.pe/backend",qe="https://saas.chimera.com.pe/oauth",K=(e=qe)=>({login:(r,a)=>z({url:`${e}/oauth/token`,headers:{"content-type":"application/x-www-form-urlencoded",Authorization:`Basic ${r}`},method:"post",data:{username:a.correo,password:a.password,grant_type:"password"}}),refreshToken:(r,a)=>z({url:`${e}/oauth/token`,headers:{"content-type":"application/x-www-form-urlencoded",Authorization:`Basic ${r}`},method:"post",data:{refresh_token:a,grant_type:"refresh_token"}})}),X=m.createSlice({name:"login",initialState:{cargando:!1,autenticado:!1,token:null,refreshToken:null,expiracion:null,usuario:null,perfiles:[],error:null},reducers:{logout:e=>{e.cargando=!1,e.autenticado=!1,e.token=null,e.refreshToken=null,e.expiracion=null,e.usuario=null,e.perfiles=[],e.error=null}},extraReducers(e){e.addCase(j.pending,r=>{r.cargando=!0,r.error=null}).addCase(j.fulfilled,(r,a)=>{const n=a.payload.access_token,i=be(n),d=new Date;d.setSeconds(d.getSeconds()+a.payload.expires_in),r.cargando=!1,r.autenticado=!0,r.token=n,r.refreshToken=a.payload.refresh_token,r.expiracion=d.getTime(),r.usuario=i.name,r.perfiles=i.authorities}).addCase(j.rejected,(r,a)=>{var n;console.log(a),r.cargando=!1,r.autenticado=!1,r.token=null,r.refreshToken=null,r.expiracion=null,r.usuario=null,r.perfiles=[],r.error=(n=a.error)==null?void 0:n.message}).addCase(w.pending,r=>{r.cargando=!0}).addCase(w.fulfilled,(r,a)=>{const n=new Date;n.setSeconds(n.getSeconds()+a.payload.expires_in),r.token=a.payload.access_token,r.refreshToken=a.payload.refresh_token,r.expiracion=n.getTime()}).addCase(w.rejected,(r,a)=>{var n;r.cargando=!1,r.autenticado=!1,r.token=null,r.refreshToken=null,r.expiracion=null,r.usuario=null,r.perfiles=[],r.error=(n=a.error)==null?void 0:n.message})}}),j=m.createAsyncThunk("login/requestToken",async e=>(await K(e.devURL).login(e.clientCredentials,e.data)).data),w=m.createAsyncThunk("login/refreshToken",async(e,r,a)=>(await K(e).refreshToken(r,a)).data),{logout:W}=X.actions,ze=e=>e.token,De=e=>e.usuario,Ae=e=>e.perfiles,Ie=X.reducer,Z=m.createSlice({name:"notificacion",initialState:[],reducers:{mostrarNotificacion:(e,r)=>{e.push(r.payload)},ocultarNotificacion:e=>{e.pop()}}}),{mostrarNotificacion:Le,ocultarNotificacion:Me}=Z.actions,Fe=Z.reducer,Ne=(e=Oe,r)=>z({url:`${e}/identidad/`,params:{codigoAplicacion:r}}),D={primary:"#1C6CCC",secondary:"#17A7FF",error:"#f44336",warning:"#ff9800",info:"#2196f3",success:"#4caf50"},Ge=m.createSlice({name:"inicializar",initialState:{inicializando:!0,inicializado:!1,instancia:{color:D},error:null},extraReducers(e){e.addCase(x.pending,r=>{r.inicializando=!0}).addCase(x.fulfilled,(r,a)=>{r.inicializando=!1,r.inicializado=!0,r.instancia={...a.payload,abreviatura:a.payload.nombre.match(/\b([A-Z])/g).join(""),color:{...D,...a.payload.color}},r.error=null}).addCase(x.rejected,(r,a)=>{r.inicializando=!1,r.inicializado=!1,r.instancia={color:D},r.error=a.payload})}}),x=m.createAsyncThunk("inicializar",async e=>(await Ne(e.devURL,e.aplicacion)).data),Ee=e=>e.instancia,He=Ge.reducer,Ue=e=>m.configureStore({reducer:{ui:ke,aplicacion:He,login:Ie,notificaciones:Fe,...e}}),Be=()=>{const[e,r]=p.useState(!1),a=u.useDispatch(),n=S.useTranslate(),i=u.useSelector(l=>l.notificaciones[0]);p.useEffect(()=>{r(!!i)},[i]);const d=()=>{r(!1),a(Me())};return t.jsx(c.Snackbar,{open:e,message:(i==null?void 0:i.mensaje)&&i.tipo==="default"&&n(i.mensaje),autoHideDuration:5e3,onClose:d,children:(i==null?void 0:i.mensaje)&&i.tipo!=="default"&&t.jsx(c.Alert,{severity:i.tipo,children:n(i.mensaje)})})},Ve={es:{inicializar:{error:{titulo:"Error iniciando aplicación",mensaje:"No fue posible conectarnos con el servicio"}},login:{titulo:"Acceder al sistema",correo:"Correo electrónico",password:"Contraseña",ingresar:"Acceder",validacion:{correo:"Debe ingresar una dirección de correo",password:"Debe ingresar una contraseña"},error:"Usuario o contraseña incorrectos"},copy:"Todos los derechos reservados "}},Je={en:N.enGB,es:N.es},Q=({messages:e,children:r})=>{const a=u.useSelector(n=>n.ui.idioma);return t.jsx(S.I18n,{locale:a,messages:e[a],children:t.jsx(Se.LocalizationProvider,{dateAdapter:$e.AdapterDateFns,adapterLocale:Je[a],children:r})})};Q.propTypes={messages:s.object,children:s.element.isRequired};const Ke=()=>{const e=je();if(!(e!=null&&e.length))return;const r=e[0];return r.indexOf("-")?r.substring(0,r.indexOf("-")):r},Y=({messages:e,idiomaDefecto:r,children:a})=>{const n=u.useDispatch(),i=Ke();p.useEffect(()=>{let l=Reflect.ownKeys(e)[0];i&&Object.hasOwn(e,i)?l=i:r&&Object.hasOwn(e,r)&&(l=r),n(Te(l))},[n,e,r,i]);const d={};return Object.keys(e).forEach(l=>{d[l]={...e[l],saas:Ve[l]}}),t.jsx(Q,{messages:d,children:a})};Y.propTypes={messages:s.object,idiomaDefecto:s.string,children:s.element.isRequired};const P=({children:e})=>{const r=u.useDispatch(),{instancia:a}=u.useSelector(l=>l.aplicacion),n=u.useSelector(l=>l.ui.tema),i=c.useMediaQuery("(prefers-color-scheme: dark)");p.useEffect(()=>{r(xe(i?"dark":"light"))},[r,i]);const d=p.useMemo(()=>G.createTheme({palette:{mode:n,primary:{main:a.color.primary},secondary:{main:a.color.secondary},error:{main:a.color.error},warning:{main:a.color.warning},info:{main:a.color.info},success:{main:a.color.success},...n==="light"&&{background:{default:E.grey.A200,paper:E.grey[100]}}},shape:{borderRadius:6}}),[n,a]);return t.jsxs(G.ThemeProvider,{theme:d,children:[t.jsx(c.CssBaseline,{}),e]})};P.propTypes={children:s.element.isRequired};const R=e=>{const r=u.useDispatch(),a=u.useSelector(i=>i.login),n=u.useSelector(i=>i.aplicacion.instancia);return p.useEffect(()=>{a.autenticado&&a.expiracion&&new Date(a.expiracion)<new Date&&(a.refreshToken?r(w(e,n.clientCredentials,a.refreshToken)):r(W()))},[e,n.clientCredentials,a,r]),a.autenticado},ee=()=>{const e=u.useDispatch();return p.useCallback((r,a="default")=>{e(Le({mensaje:r,tipo:a}))},[e])},re=({devURL:e})=>{const r=u.useDispatch(),a=S.useTranslate(),n=ee(),{cargando:i,error:d}=u.useSelector(h=>h.login),l=u.useSelector(h=>h.aplicacion.instancia),M=h=>{r(j({devURL:e,clientCredentials:l.clientCredentials,data:{correo:h.correo,password:h.password}}))},En=h=>{const F={correo:void 0,password:void 0};return h.correo||(F.correo=a("saas.login.validacion.correo")),h.password||(F.password=a("saas.login.validacion.password")),F};return p.useEffect(()=>{d&&n("saas.login.error","error")},[n,d]),t.jsx(we.Form,{onSubmit:M,validate:En,render:({handleSubmit:h})=>t.jsxs("form",{onSubmit:h,children:[t.jsx(U.TextField,{id:"correo",name:"correo",label:a("saas.login.correo"),variant:"outlined",autoComplete:"off",disabled:i,autoFocus:!0,InputProps:{startAdornment:t.jsx(c.InputAdornment,{position:"start",children:t.jsx(H.Email,{color:"primary"})})}}),t.jsx(U.TextField,{id:"password",name:"password",type:"password",label:a("saas.login.password"),variant:"outlined",autoComplete:"current-password",disabled:i,InputProps:{startAdornment:t.jsx(c.InputAdornment,{position:"start",children:t.jsx(H.Lock,{color:"primary"})})}}),t.jsxs(c.Grid,{container:!0,children:[t.jsx(c.Grid,{item:!0,xs:6}),t.jsx(c.Grid,{item:!0,xs:6,align:"right",children:t.jsx(c.Button,{variant:"contained",color:"primary",type:"submit",disabled:i,children:i?t.jsx(c.CircularProgress,{size:24,thickness:4}):a("saas.login.ingresar")})})]})]})})};re.propTypes={devURL:s.string};const ae=({devURL:e})=>{const r=u.useSelector(l=>l.aplicacion.instancia),a=S.useTranslate(),n=_.useLocation(),i=R(e),{from:d}=n.state||{from:{pathname:"/"}};return!r.requiereLogin||i?t.jsx(_.Navigate,{to:d}):t.jsxs(c.Box,{sx:{position:"relative",display:"flex",flexDirection:"column",flexGrow:1,minHeight:"100vh",backgroundColor:"primary.main","&::before":{content:'""',backgroundImage:`url(${r.logo})`,backgroundSize:"contain",backgroundRepeat:"no-repeat",backgroundPosition:"right",position:"absolute",top:"20%",bottom:0,right:0,width:"50%",opacity:.02,filter:"grayscale(100%)"}},children:[t.jsx(c.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",flexGrow:1},children:t.jsx(c.Container,{maxWidth:"md",children:t.jsxs(c.Grid,{container:!0,spacing:3,children:[t.jsxs(c.Grid,{item:!0,xs:12,lg:5,align:"center",children:[t.jsx("img",{src:r.logo,alt:r.nombre,style:{maxWidth:"100%"}}),t.jsx(c.Typography,{variant:"h3",align:"center",children:a("aplicacion.nombre",{smart_count:1})}),t.jsx(c.Typography,{variant:"h5",align:"center",children:r.nombre})]}),t.jsx(c.Grid,{item:!0,xs:12,lg:7,sx:{display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:t.jsxs(c.Card,{elevation:5,children:[t.jsx(c.CardHeader,{title:a("saas.login.titulo"),titleTypographyProps:{align:"center"}}),t.jsx(c.CardContent,{sx:{"& .MuiTextField-root":{mb:2}},children:t.jsx(re,{devURL:e})})]})})]})})}),t.jsx(c.AppBar,{position:"static",color:"primary",children:t.jsx(c.Toolbar,{sx:{justifyContent:"center"},children:t.jsxs(c.Typography,{variant:"caption",children:[a("saas.copy"),t.jsx(c.Link,{href:"//chimera.com.pe",color:"inherit",target:"_blank",rel:"noreferrer",children:"Chimera Software"})]})})})]})};ae.propTypes={devURL:s.string};const ne=({devURL:e,redirectTo:r,children:a})=>{const n=_.useLocation();return R(e)?a:t.jsx(_.Navigate,{to:r,state:{from:n},replace:!0})};ne.propTypes={devURL:s.string,redirectTo:s.string.isRequired,children:s.element.isRequired};const te=({devURL:e,requiereLogin:r,children:a})=>t.jsx(_.BrowserRouter,{children:t.jsxs(_.Routes,{children:[t.jsx(_.Route,{path:"/login",element:t.jsx(ae,{devURL:e})}),t.jsx(_.Route,{path:"/*",element:r?t.jsx(ne,{devURL:e,redirectTo:"/login",children:a}):a})]})});te.propTypes={devURL:s.string,requiereLogin:s.bool,children:s.element.isRequired};const ie=({devURL:e,children:r})=>{const a=u.useSelector(n=>n.aplicacion);return t.jsx(c.Box,{sx:{display:"flex",flexDirection:"column",minHeight:"100vh",justifyContent:"flex-start",backgroundColor:"background.default"},children:a.inicializando?t.jsx(B,{}):a.error||!a.inicializado?t.jsx(V,{titulo:"saas.inicializar.error.titulo",texto:"saas.inicializar.error.mensaje"}):t.jsxs(t.Fragment,{children:[t.jsx(te,{devURL:e,requiereLogin:a.instancia.requiereLogin,children:r}),t.jsx(Be,{})]})})};ie.propTypes={devURL:s.string,children:s.element.isRequired};const oe=({aplicacion:e,devSaasURL:r,devAuthURL:a,messages:n,idiomaDefecto:i,children:d})=>{const l=u.useDispatch();return p.useEffect(()=>{l(x({devURL:r,aplicacion:e}))},[l,e,r]),t.jsx(Y,{messages:n,idiomaDefecto:i,children:t.jsx(P,{children:t.jsx(ie,{devURL:a,children:d})})})};oe.propTypes={aplicacion:s.string.isRequired,devSaasURL:s.string,devAuthURL:s.string,messages:s.object.isRequired,idiomaDefecto:s.string,children:s.element.isRequired};const se=({customReducers:e,aplicacion:r,devSaasURL:a,devAuthURL:n,dev:i=!1,idiomaDefecto:d,messages:l,children:M})=>t.jsx(u.Provider,{store:Ue(e),children:t.jsx(oe,{aplicacion:r,devSaasURL:i?a:void 0,devAuthURL:i?n:void 0,idiomaDefecto:d,messages:l,children:M})});se.propTypes={customReducers:s.object,aplicacion:s.string.isRequired,devSaasURL:s.string,devAuthURL:s.string,dev:s.bool,idiomaDefecto:s.string,messages:s.object,children:s.element.isRequired};var T=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Xe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var We=typeof T=="object"&&T&&T.Object===Object&&T,Ze=We,Qe=Ze,Ye=typeof self=="object"&&self&&self.Object===Object&&self,Pe=Qe||Ye||Function("return this")(),A=Pe,Re=A,er=Re.Symbol,ce=er,le=ce,de=Object.prototype,rr=de.hasOwnProperty,ar=de.toString,$=le?le.toStringTag:void 0;function nr(e){var r=rr.call(e,$),a=e[$];try{e[$]=void 0;var n=!0}catch{}var i=ar.call(e);return n&&(r?e[$]=a:delete e[$]),i}var tr=nr,ir=Object.prototype,or=ir.toString;function sr(e){return or.call(e)}var cr=sr,ue=ce,lr=tr,dr=cr,ur="[object Null]",hr="[object Undefined]",he=ue?ue.toStringTag:void 0;function fr(e){return e==null?e===void 0?hr:ur:he&&he in Object(e)?lr(e):dr(e)}var pr=fr;function gr(e){var r=typeof e;return e!=null&&(r=="object"||r=="function")}var fe=gr,vr=pr,mr=fe,_r="[object AsyncFunction]",yr="[object Function]",Cr="[object GeneratorFunction]",br="[object Proxy]";function Sr(e){if(!mr(e))return!1;var r=vr(e);return r==yr||r==Cr||r==_r||r==br}var $r=Sr,jr=A,wr=jr["__core-js_shared__"],xr=wr,I=xr,pe=function(){var e=/[^.]+$/.exec(I&&I.keys&&I.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Tr(e){return!!pe&&pe in e}var kr=Tr,Or=Function.prototype,qr=Or.toString;function zr(e){if(e!=null){try{return qr.call(e)}catch{}try{return e+""}catch{}}return""}var Dr=zr,Ar=$r,Ir=kr,Lr=fe,Mr=Dr,Fr=/[\\^$.*+?()[\]{}|]/g,Nr=/^\[object .+?Constructor\]$/,Gr=Function.prototype,Er=Object.prototype,Hr=Gr.toString,Ur=Er.hasOwnProperty,Br=RegExp("^"+Hr.call(Ur).replace(Fr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Vr(e){if(!Lr(e)||Ir(e))return!1;var r=Ar(e)?Br:Nr;return r.test(Mr(e))}var Jr=Vr;function Kr(e,r){return e==null?void 0:e[r]}var Xr=Kr,Wr=Jr,Zr=Xr;function Qr(e,r){var a=Zr(e,r);return Wr(a)?a:void 0}var ge=Qr,Yr=ge,Pr=Yr(Object,"create"),k=Pr,ve=k;function Rr(){this.__data__=ve?ve(null):{},this.size=0}var ea=Rr;function ra(e){var r=this.has(e)&&delete this.__data__[e];return this.size-=r?1:0,r}var aa=ra,na=k,ta="__lodash_hash_undefined__",ia=Object.prototype,oa=ia.hasOwnProperty;function sa(e){var r=this.__data__;if(na){var a=r[e];return a===ta?void 0:a}return oa.call(r,e)?r[e]:void 0}var ca=sa,la=k,da=Object.prototype,ua=da.hasOwnProperty;function ha(e){var r=this.__data__;return la?r[e]!==void 0:ua.call(r,e)}var fa=ha,pa=k,ga="__lodash_hash_undefined__";function va(e,r){var a=this.__data__;return this.size+=this.has(e)?0:1,a[e]=pa&&r===void 0?ga:r,this}var ma=va,_a=ea,ya=aa,Ca=ca,ba=fa,Sa=ma;function y(e){var r=-1,a=e==null?0:e.length;for(this.clear();++r<a;){var n=e[r];this.set(n[0],n[1])}}y.prototype.clear=_a,y.prototype.delete=ya,y.prototype.get=Ca,y.prototype.has=ba,y.prototype.set=Sa;var $a=y;function ja(){this.__data__=[],this.size=0}var wa=ja;function xa(e,r){return e===r||e!==e&&r!==r}var Ta=xa,ka=Ta;function Oa(e,r){for(var a=e.length;a--;)if(ka(e[a][0],r))return a;return-1}var O=Oa,qa=O,za=Array.prototype,Da=za.splice;function Aa(e){var r=this.__data__,a=qa(r,e);if(a<0)return!1;var n=r.length-1;return a==n?r.pop():Da.call(r,a,1),--this.size,!0}var Ia=Aa,La=O;function Ma(e){var r=this.__data__,a=La(r,e);return a<0?void 0:r[a][1]}var Fa=Ma,Na=O;function Ga(e){return Na(this.__data__,e)>-1}var Ea=Ga,Ha=O;function Ua(e,r){var a=this.__data__,n=Ha(a,e);return n<0?(++this.size,a.push([e,r])):a[n][1]=r,this}var Ba=Ua,Va=wa,Ja=Ia,Ka=Fa,Xa=Ea,Wa=Ba;function C(e){var r=-1,a=e==null?0:e.length;for(this.clear();++r<a;){var n=e[r];this.set(n[0],n[1])}}C.prototype.clear=Va,C.prototype.delete=Ja,C.prototype.get=Ka,C.prototype.has=Xa,C.prototype.set=Wa;var Za=C,Qa=ge,Ya=A,Pa=Qa(Ya,"Map"),Ra=Pa,me=$a,en=Za,rn=Ra;function an(){this.size=0,this.__data__={hash:new me,map:new(rn||en),string:new me}}var nn=an;function tn(e){var r=typeof e;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?e!=="__proto__":e===null}var on=tn,sn=on;function cn(e,r){var a=e.__data__;return sn(r)?a[typeof r=="string"?"string":"hash"]:a.map}var q=cn,ln=q;function dn(e){var r=ln(this,e).delete(e);return this.size-=r?1:0,r}var un=dn,hn=q;function fn(e){return hn(this,e).get(e)}var pn=fn,gn=q;function vn(e){return gn(this,e).has(e)}var mn=vn,_n=q;function yn(e,r){var a=_n(this,e),n=a.size;return a.set(e,r),this.size+=a.size==n?0:1,this}var Cn=yn,bn=nn,Sn=un,$n=pn,jn=mn,wn=Cn;function b(e){var r=-1,a=e==null?0:e.length;for(this.clear();++r<a;){var n=e[r];this.set(n[0],n[1])}}b.prototype.clear=bn,b.prototype.delete=Sn,b.prototype.get=$n,b.prototype.has=jn,b.prototype.set=wn;var xn=b,_e=xn,Tn="Expected a function";function L(e,r){if(typeof e!="function"||r!=null&&typeof r!="function")throw new TypeError(Tn);var a=function(){var n=arguments,i=r?r.apply(this,n):n[0],d=a.cache;if(d.has(i))return d.get(i);var l=e.apply(this,n);return a.cache=d.set(i,l)||d,l};return a.cache=new(L.Cache||_e),a}L.Cache=_e;var kn=L;const ye=Xe(kn),On=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,g=e=>typeof e>"u"||e===null||e===""||Array.isArray(e)&&e.length===0,f=(e,r,a,n)=>typeof e=="function"?e({args:r,value:a,values:n}):r?{message:e,args:r}:e,v=e=>ye(e,(...r)=>JSON.stringify(r)),qn=(...e)=>(r,a,n)=>(Array.isArray(e[0])?e[0]:e).reduce((d,l)=>d||typeof l=="function"&&l(r,a,n),void 0),zn=v((e="validacion.obligatorio")=>Object.assign((r,a)=>g(r)?f(e,void 0,r,a):void 0,{isRequired:!0})),Dn=v((e="validacion.obligatorio")=>Object.assign((r,a)=>g(r)||!r?f(e,void 0,r,a):void 0,{isRequired:!0})),An=v((e="validacion.numero")=>(r,a)=>!g(r)&&isNaN(r)?f(e,void 0,r,a):void 0),In=v((e,r="validacion.longitud.minima")=>(a,n)=>!g(a)&&a.length<e?f(r,void 0,a,n):void 0),Ln=v((e,r="validacion.longitud.maxima")=>(a,n)=>!g(a)&&a.length>e?f(r,void 0,a,n):void 0),Mn=v((e,r="validacion.minimo")=>(a,n)=>!g(a)&&parseFloat(a)<e?f(r,void 0,a,n):void 0),Fn=v((e,r="validacion.maximo")=>(a,n)=>!g(a)&&parseFloat(a)>e?f(r,void 0,a,n):void 0),Ce=ye((e,r="validacion.regex")=>(a,n)=>!g(a)&&typeof a=="string"&&!e.test(a)?f(r,void 0,a,n):void 0,(e,r)=>e.toString()+r),Nn=v((e="validacion.correo")=>Ce(On,e)),Gn=v((e,r,a="validacion.remote")=>(n,i,d)=>d.active&&!g(n)&&e(n,r).then(l=>l?f(a,void 0,n,i):void 0).catch(l=>f(l.message,void 0,n,i)));o.Cargando=B,o.Error=V,o.SaasApp=se,o.composeValidators=qn,o.email=Nn,o.getInstancia=Ee,o.getPerfiles=Ae,o.getToken=ze,o.getUsuario=De,o.logout=W,o.max=Fn,o.maxLength=Ln,o.min=Mn,o.minLength=In,o.number=An,o.regex=Ce,o.remote=Gn,o.required=zn,o.requiredNotFalse=Dn,o.useNotificar=ee,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chimera-pe/react-saas",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"jwt-decode": "^3.1.2",
|
|
23
23
|
"mui-rff": "^6.2.3",
|
|
24
24
|
"navigator-languages": "^2.0.2",
|
|
25
|
+
"node-polyglot": "^2.5.0",
|
|
25
26
|
"react": ">=18",
|
|
26
27
|
"react-dom": ">=18",
|
|
27
28
|
"react-final-form": "^6.5.9",
|