@chimera-pe/react-saas 0.0.1 → 0.0.3
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 +469 -0
- package/dist/react-saas.umd.cjs +1 -0
- package/package.json +27 -20
- package/.eslintrc.cjs +0 -20
- package/src/Constantes.js +0 -2
- package/src/api/inicializarApi.jsx +0 -9
- package/src/api/loginApi.jsx +0 -30
- package/src/components/Cargando.jsx +0 -15
- package/src/components/Error.jsx +0 -31
- package/src/components/Idioma.jsx +0 -48
- package/src/components/Inicializar.jsx +0 -64
- package/src/components/Login.jsx +0 -202
- package/src/components/MainRouter.jsx +0 -35
- package/src/components/Notificacion.jsx +0 -36
- package/src/components/SaasApp.jsx +0 -30
- package/src/components/Tema.jsx +0 -59
- package/src/components/index.jsx +0 -9
- package/src/hooks/index.jsx +0 -7
- package/src/hooks/useCheckLogin.jsx +0 -24
- package/src/hooks/useNotificar.jsx +0 -12
- package/src/i18n/es.jsx +0 -22
- package/src/i18n/index.jsx +0 -7
- package/src/index.js +0 -12
- package/src/redux/index.jsx +0 -17
- package/src/redux/inicializarSlice.jsx +0 -57
- package/src/redux/loginSlice.jsx +0 -94
- package/src/redux/notificacionSlice.jsx +0 -20
- package/src/redux/store.jsx +0 -15
- package/src/redux/uiSlice.jsx +0 -24
- package/vite.config.js +0 -27
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
import { jsx as n, jsxs as l, Fragment as M } from "react/jsx-runtime";
|
|
2
|
+
import { Box as f, CircularProgress as L, Alert as R, AlertTitle as U, Snackbar as H, useMediaQuery as O, CssBaseline as W, Container as Q, Grid as p, Typography as T, Card as Z, CardHeader as J, CardContent as K, AppBar as V, Toolbar as X, Link as Y, InputAdornment as A, Button as ee } from "@mui/material";
|
|
3
|
+
import { useTranslate as k, I18n as re } from "react-polyglot";
|
|
4
|
+
import h from "prop-types";
|
|
5
|
+
import { useDispatch as u, useSelector as d, Provider as oe } from "react-redux";
|
|
6
|
+
import { createSlice as C, createAsyncThunk as v, configureStore as ne } from "@reduxjs/toolkit";
|
|
7
|
+
import z from "axios";
|
|
8
|
+
import ie from "jwt-decode";
|
|
9
|
+
import { useState as ae, useEffect as m, useMemo as te, useCallback as ce } from "react";
|
|
10
|
+
import { enGB as se, es as le } from "date-fns/locale";
|
|
11
|
+
import { LocalizationProvider as de } from "@mui/x-date-pickers";
|
|
12
|
+
import { AdapterDateFns as ue } from "@mui/x-date-pickers/AdapterDateFns";
|
|
13
|
+
import { createTheme as pe, ThemeProvider as me } from "@mui/material/styles";
|
|
14
|
+
import { grey as j } from "@mui/material/colors";
|
|
15
|
+
import { useLocation as _, Navigate as $, BrowserRouter as fe, Routes as he, Route as I } from "react-router-dom";
|
|
16
|
+
import { Email as ge, Lock as ye } from "@mui/icons-material";
|
|
17
|
+
import { Form as xe } from "react-final-form";
|
|
18
|
+
import { TextField as D } from "mui-rff";
|
|
19
|
+
const ke = () => /* @__PURE__ */ n(f, { sx: {
|
|
20
|
+
display: "flex",
|
|
21
|
+
flexDirection: "column",
|
|
22
|
+
flexGrow: 1,
|
|
23
|
+
justifyContent: "center",
|
|
24
|
+
alignItems: "center"
|
|
25
|
+
}, children: /* @__PURE__ */ n(L, {}) }), F = ({ titulo: o, texto: e, align: r = "center", severity: i = "error" }) => {
|
|
26
|
+
const a = k();
|
|
27
|
+
return /* @__PURE__ */ n(f, { sx: {
|
|
28
|
+
display: "flex",
|
|
29
|
+
flexDirection: "column",
|
|
30
|
+
flexGrow: 1,
|
|
31
|
+
justifyContent: "center",
|
|
32
|
+
alignItems: r
|
|
33
|
+
}, children: /* @__PURE__ */ l(R, { severity: i, children: [
|
|
34
|
+
/* @__PURE__ */ n(U, { children: a(o) }),
|
|
35
|
+
e && a(e)
|
|
36
|
+
] }) });
|
|
37
|
+
};
|
|
38
|
+
F.propTypes = {
|
|
39
|
+
titulo: h.string.isRequired,
|
|
40
|
+
texto: h.string,
|
|
41
|
+
align: h.string,
|
|
42
|
+
severity: h.string
|
|
43
|
+
};
|
|
44
|
+
const P = C({
|
|
45
|
+
name: "ui",
|
|
46
|
+
initialState: {
|
|
47
|
+
tema: "light",
|
|
48
|
+
temaSeleccionado: !1,
|
|
49
|
+
idioma: "es"
|
|
50
|
+
},
|
|
51
|
+
reducers: {
|
|
52
|
+
cambiarTema: (o, e) => {
|
|
53
|
+
o.tema = e.payload, o.temaSeleccionado = !0, localStorage.setItem("tema", e.payload);
|
|
54
|
+
},
|
|
55
|
+
cambiarIdioma: (o, e) => {
|
|
56
|
+
o.idioma = e.payload;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}), { cambiarTema: Ce, cambiarIdioma: be } = P.actions, we = P.reducer, Te = "https://saas.chimera.com.pe/backend", Se = "https://saas.chimera.com.pe/oauth", B = (o = Se) => ({
|
|
60
|
+
login: (e, r) => z({
|
|
61
|
+
url: `${o}/oauth/token`,
|
|
62
|
+
headers: {
|
|
63
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
64
|
+
Authorization: `Basic ${e}`
|
|
65
|
+
},
|
|
66
|
+
method: "post",
|
|
67
|
+
data: {
|
|
68
|
+
username: r.correo,
|
|
69
|
+
password: r.password,
|
|
70
|
+
grant_type: "password"
|
|
71
|
+
}
|
|
72
|
+
}),
|
|
73
|
+
refreshToken: (e, r) => z({
|
|
74
|
+
url: `${o}/oauth/token`,
|
|
75
|
+
headers: {
|
|
76
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
77
|
+
Authorization: `Basic ${e}`
|
|
78
|
+
},
|
|
79
|
+
method: "post",
|
|
80
|
+
data: {
|
|
81
|
+
refresh_token: r,
|
|
82
|
+
grant_type: "refresh_token"
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
}), N = C({
|
|
86
|
+
name: "login",
|
|
87
|
+
initialState: {
|
|
88
|
+
cargando: !1,
|
|
89
|
+
autenticado: !1,
|
|
90
|
+
token: null,
|
|
91
|
+
refreshToken: null,
|
|
92
|
+
expiracion: null,
|
|
93
|
+
usuario: null,
|
|
94
|
+
perfiles: [],
|
|
95
|
+
error: null
|
|
96
|
+
},
|
|
97
|
+
reducers: {
|
|
98
|
+
logout: (o) => {
|
|
99
|
+
o.cargando = !1, o.autenticado = !1, o.token = null, o.refreshToken = null, o.expiracion = null, o.usuario = null, o.perfiles = [], o.error = null;
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
extraReducers(o) {
|
|
103
|
+
o.addCase(g.pending, (e) => {
|
|
104
|
+
e.cargando = !0, e.error = null;
|
|
105
|
+
}).addCase(g.fulfilled, (e, r) => {
|
|
106
|
+
const i = r.payload.access_token, a = ie(i), t = /* @__PURE__ */ new Date();
|
|
107
|
+
t.setSeconds(t.getSeconds() + r.payload.expires_in), e.cargando = !1, e.autenticado = !0, e.token = i, e.refreshToken = r.payload.refresh_token, e.expiracion = t.getTime(), e.usuario = a.name, e.perfiles = a.authorities;
|
|
108
|
+
}).addCase(g.rejected, (e, r) => {
|
|
109
|
+
var i;
|
|
110
|
+
console.log(r), e.cargando = !1, e.autenticado = !1, e.token = null, e.refreshToken = null, e.expiracion = null, e.usuario = null, e.perfiles = [], e.error = (i = r.error) == null ? void 0 : i.message;
|
|
111
|
+
}).addCase(y.pending, (e) => {
|
|
112
|
+
e.cargando = !0;
|
|
113
|
+
}).addCase(y.fulfilled, (e, r) => {
|
|
114
|
+
const i = /* @__PURE__ */ new Date();
|
|
115
|
+
i.setSeconds(i.getSeconds() + r.payload.expires_in), e.token = r.payload.access_token, e.refreshToken = r.payload.refresh_token, e.expiracion = i.getTime();
|
|
116
|
+
}).addCase(y.rejected, (e, r) => {
|
|
117
|
+
var i;
|
|
118
|
+
e.cargando = !1, e.autenticado = !1, e.token = null, e.refreshToken = null, e.expiracion = null, e.usuario = null, e.perfiles = [], e.error = (i = r.error) == null ? void 0 : i.message;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}), g = v("login/requestToken", async (o) => (await B(o.devURL).login(o.clientCredentials, o.data)).data), y = v("login/refreshToken", async (o, e, r) => (await B(o).refreshToken(e, r)).data), { logout: ze } = N.actions, ve = N.reducer, q = C({
|
|
122
|
+
name: "notificacion",
|
|
123
|
+
initialState: [],
|
|
124
|
+
reducers: {
|
|
125
|
+
mostrarNotificacion: (o, e) => {
|
|
126
|
+
o.push(e.payload);
|
|
127
|
+
},
|
|
128
|
+
ocultarNotificacion: (o) => {
|
|
129
|
+
o.pop();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}), { mostrarNotificacion: Ae, ocultarNotificacion: je } = q.actions, Ie = q.reducer, De = (o = Te, e) => z({
|
|
133
|
+
url: `${o}/identidad/`,
|
|
134
|
+
params: {
|
|
135
|
+
codigoAplicacion: e
|
|
136
|
+
}
|
|
137
|
+
}), S = {
|
|
138
|
+
primary: "#1C6CCC",
|
|
139
|
+
secondary: "#17A7FF",
|
|
140
|
+
error: "#f44336",
|
|
141
|
+
warning: "#ff9800",
|
|
142
|
+
info: "#2196f3",
|
|
143
|
+
success: "#4caf50"
|
|
144
|
+
}, Le = C({
|
|
145
|
+
name: "inicializar",
|
|
146
|
+
initialState: {
|
|
147
|
+
inicializando: !0,
|
|
148
|
+
inicializado: !1,
|
|
149
|
+
instancia: {
|
|
150
|
+
color: S
|
|
151
|
+
},
|
|
152
|
+
error: null
|
|
153
|
+
},
|
|
154
|
+
extraReducers(o) {
|
|
155
|
+
o.addCase(x.pending, (e) => {
|
|
156
|
+
e.inicializando = !0;
|
|
157
|
+
}).addCase(x.fulfilled, (e, r) => {
|
|
158
|
+
e.inicializando = !1, e.inicializado = !0, e.instancia = {
|
|
159
|
+
...r.payload,
|
|
160
|
+
abreviatura: r.payload.nombre.match(/\b([A-Z])/g).join(""),
|
|
161
|
+
color: {
|
|
162
|
+
...S,
|
|
163
|
+
...r.payload.color
|
|
164
|
+
}
|
|
165
|
+
}, e.error = null;
|
|
166
|
+
}).addCase(x.rejected, (e, r) => {
|
|
167
|
+
e.inicializando = !1, e.inicializado = !1, e.instancia = {
|
|
168
|
+
color: S
|
|
169
|
+
}, e.error = r.payload;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}), x = v("inicializar", async (o) => (await De(o.devURL, o.aplicacion)).data), Re = Le.reducer, _e = (o) => ne({
|
|
173
|
+
reducer: {
|
|
174
|
+
ui: we,
|
|
175
|
+
aplicacion: Re,
|
|
176
|
+
login: ve,
|
|
177
|
+
notificaciones: Ie,
|
|
178
|
+
...o
|
|
179
|
+
}
|
|
180
|
+
}), $e = () => {
|
|
181
|
+
const [o, e] = ae(!1), r = u(), i = k(), a = d((c) => c.notificaciones[0]);
|
|
182
|
+
m(() => {
|
|
183
|
+
e(!!a);
|
|
184
|
+
}, [a]);
|
|
185
|
+
const t = () => {
|
|
186
|
+
e(!1), r(je());
|
|
187
|
+
};
|
|
188
|
+
return /* @__PURE__ */ n(
|
|
189
|
+
H,
|
|
190
|
+
{
|
|
191
|
+
open: o,
|
|
192
|
+
message: a && a.mensaje && a.tipo === "default" && i(a.mensaje),
|
|
193
|
+
autoHideDuration: 5e3,
|
|
194
|
+
onClose: t,
|
|
195
|
+
children: a && a.mensaje && a.tipo !== "default" && /* @__PURE__ */ n(R, { severity: a.tipo, children: i(a.mensaje) })
|
|
196
|
+
}
|
|
197
|
+
);
|
|
198
|
+
}, Fe = {
|
|
199
|
+
inicializar: {
|
|
200
|
+
error: {
|
|
201
|
+
titulo: "Error iniciando aplicación",
|
|
202
|
+
mensaje: "No fue posible conectarnos con el servicio"
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
login: {
|
|
206
|
+
titulo: "Acceder al sistema",
|
|
207
|
+
correo: "Correo electrónico",
|
|
208
|
+
password: "Contraseña",
|
|
209
|
+
ingresar: "Acceder",
|
|
210
|
+
validacion: {
|
|
211
|
+
correo: "Debe ingresar una dirección de correo",
|
|
212
|
+
password: "Debe ingresar una contraseña"
|
|
213
|
+
},
|
|
214
|
+
error: "Usuario o contraseña incorrectos"
|
|
215
|
+
},
|
|
216
|
+
copy: "Todos los derechos reservados "
|
|
217
|
+
}, Pe = {
|
|
218
|
+
es: Fe
|
|
219
|
+
}, Be = { en: se, es: le }, Ne = ({ messages: o, children: e }) => {
|
|
220
|
+
const r = d((i) => i.ui.idioma);
|
|
221
|
+
return /* @__PURE__ */ n(re, { locale: r, messages: o[r], children: /* @__PURE__ */ n(de, { dateAdapter: ue, adapterLocale: Be[r], children: e }) });
|
|
222
|
+
}, qe = ({ messages: o, idioma: e, children: r }) => {
|
|
223
|
+
const i = u();
|
|
224
|
+
m(() => {
|
|
225
|
+
e && i(be(e));
|
|
226
|
+
}, [i, e]);
|
|
227
|
+
const a = {};
|
|
228
|
+
return Object.keys(o).forEach((t) => {
|
|
229
|
+
a[t] = {
|
|
230
|
+
...o[t],
|
|
231
|
+
saas: Pe[t]
|
|
232
|
+
};
|
|
233
|
+
}), /* @__PURE__ */ n(Ne, { messages: a, children: r });
|
|
234
|
+
}, Ge = ({ children: o }) => {
|
|
235
|
+
const e = u(), { instancia: r } = d((c) => c.aplicacion), i = d((c) => c.ui.tema), a = O("(prefers-color-scheme: dark)");
|
|
236
|
+
m(() => {
|
|
237
|
+
e(Ce(a ? "dark" : "light"));
|
|
238
|
+
}, [e, a]);
|
|
239
|
+
const t = te(() => pe({
|
|
240
|
+
palette: {
|
|
241
|
+
mode: i,
|
|
242
|
+
primary: {
|
|
243
|
+
main: r.color.primary
|
|
244
|
+
},
|
|
245
|
+
secondary: {
|
|
246
|
+
main: r.color.secondary
|
|
247
|
+
},
|
|
248
|
+
error: {
|
|
249
|
+
main: r.color.error
|
|
250
|
+
},
|
|
251
|
+
warning: {
|
|
252
|
+
main: r.color.warning
|
|
253
|
+
},
|
|
254
|
+
info: {
|
|
255
|
+
main: r.color.info
|
|
256
|
+
},
|
|
257
|
+
success: {
|
|
258
|
+
main: r.color.success
|
|
259
|
+
},
|
|
260
|
+
...i === "light" && {
|
|
261
|
+
background: {
|
|
262
|
+
default: j.A200,
|
|
263
|
+
paper: j[100]
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
shape: {
|
|
268
|
+
borderRadius: 6
|
|
269
|
+
}
|
|
270
|
+
}), [i, r]);
|
|
271
|
+
return /* @__PURE__ */ l(me, { theme: t, children: [
|
|
272
|
+
/* @__PURE__ */ n(W, {}),
|
|
273
|
+
o
|
|
274
|
+
] });
|
|
275
|
+
}, G = (o) => {
|
|
276
|
+
const e = u(), r = d((a) => a.login), i = d((a) => a.aplicacion.instancia);
|
|
277
|
+
return m(() => {
|
|
278
|
+
r.autenticado && r.expiracion && new Date(r.expiracion) < /* @__PURE__ */ new Date() && (r.refreshToken ? e(y(o, i.clientCredentials, r.refreshToken)) : e(ze()));
|
|
279
|
+
}, [o, i.clientCredentials, r, e]), r.autenticado;
|
|
280
|
+
}, Ee = () => {
|
|
281
|
+
const o = u();
|
|
282
|
+
return ce((e, r = "default") => {
|
|
283
|
+
o(Ae({ mensaje: e, tipo: r }));
|
|
284
|
+
}, [o]);
|
|
285
|
+
}, Me = ({ devURL: o }) => {
|
|
286
|
+
const e = u(), r = k(), i = Ee(), { cargando: a, error: t } = d((s) => s.login), c = d((s) => s.aplicacion.instancia), b = (s) => {
|
|
287
|
+
e(g({
|
|
288
|
+
devURL: o,
|
|
289
|
+
clientCredentials: c.clientCredentials,
|
|
290
|
+
data: {
|
|
291
|
+
correo: s.correo,
|
|
292
|
+
password: s.password
|
|
293
|
+
}
|
|
294
|
+
}));
|
|
295
|
+
}, E = (s) => {
|
|
296
|
+
const w = { correo: void 0, password: void 0 };
|
|
297
|
+
return s.correo || (w.correo = r("saas.login.validacion.correo")), s.password || (w.password = r("saas.login.validacion.password")), w;
|
|
298
|
+
};
|
|
299
|
+
return m(() => {
|
|
300
|
+
t && i("saas.login.error", "error");
|
|
301
|
+
}, [i, t]), /* @__PURE__ */ n(
|
|
302
|
+
xe,
|
|
303
|
+
{
|
|
304
|
+
onSubmit: b,
|
|
305
|
+
validate: E,
|
|
306
|
+
render: ({ handleSubmit: s }) => /* @__PURE__ */ l("form", { onSubmit: s, children: [
|
|
307
|
+
/* @__PURE__ */ n(
|
|
308
|
+
D,
|
|
309
|
+
{
|
|
310
|
+
id: "correo",
|
|
311
|
+
name: "correo",
|
|
312
|
+
label: r("saas.login.correo"),
|
|
313
|
+
variant: "outlined",
|
|
314
|
+
autoComplete: "off",
|
|
315
|
+
disabled: a,
|
|
316
|
+
autoFocus: !0,
|
|
317
|
+
InputProps: {
|
|
318
|
+
startAdornment: /* @__PURE__ */ n(A, { position: "start", children: /* @__PURE__ */ n(ge, { color: "primary" }) })
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
),
|
|
322
|
+
/* @__PURE__ */ n(
|
|
323
|
+
D,
|
|
324
|
+
{
|
|
325
|
+
id: "password",
|
|
326
|
+
name: "password",
|
|
327
|
+
type: "password",
|
|
328
|
+
label: r("saas.login.password"),
|
|
329
|
+
variant: "outlined",
|
|
330
|
+
autoComplete: "current-password",
|
|
331
|
+
disabled: a,
|
|
332
|
+
InputProps: {
|
|
333
|
+
startAdornment: /* @__PURE__ */ n(A, { position: "start", children: /* @__PURE__ */ n(ye, { color: "primary" }) })
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
),
|
|
337
|
+
/* @__PURE__ */ l(p, { container: !0, children: [
|
|
338
|
+
/* @__PURE__ */ n(p, { item: !0, xs: 6 }),
|
|
339
|
+
/* @__PURE__ */ n(p, { item: !0, xs: 6, align: "right", children: /* @__PURE__ */ n(
|
|
340
|
+
ee,
|
|
341
|
+
{
|
|
342
|
+
variant: "contained",
|
|
343
|
+
color: "primary",
|
|
344
|
+
type: "submit",
|
|
345
|
+
disabled: a,
|
|
346
|
+
children: a ? /* @__PURE__ */ n(L, { size: 24, thickness: 4 }) : r("saas.login.ingresar")
|
|
347
|
+
}
|
|
348
|
+
) })
|
|
349
|
+
] })
|
|
350
|
+
] })
|
|
351
|
+
}
|
|
352
|
+
);
|
|
353
|
+
}, Ue = ({ devURL: o }) => {
|
|
354
|
+
const e = d((c) => c.aplicacion.instancia), r = k(), i = _(), a = G(o), { from: t } = i.state || { from: { pathname: "/" } };
|
|
355
|
+
return !e.requiereLogin || a ? /* @__PURE__ */ n($, { to: t }) : /* @__PURE__ */ l(f, { sx: {
|
|
356
|
+
position: "relative",
|
|
357
|
+
display: "flex",
|
|
358
|
+
flexDirection: "column",
|
|
359
|
+
flexGrow: 1,
|
|
360
|
+
minHeight: "100vh",
|
|
361
|
+
backgroundColor: "primary.main",
|
|
362
|
+
"&::before": {
|
|
363
|
+
content: '""',
|
|
364
|
+
backgroundImage: `url(${e.logo})`,
|
|
365
|
+
backgroundSize: "contain",
|
|
366
|
+
backgroundRepeat: "no-repeat",
|
|
367
|
+
backgroundPosition: "right",
|
|
368
|
+
position: "absolute",
|
|
369
|
+
top: "20%",
|
|
370
|
+
bottom: 0,
|
|
371
|
+
right: 0,
|
|
372
|
+
width: "50%",
|
|
373
|
+
opacity: 0.02,
|
|
374
|
+
filter: "grayscale(100%)"
|
|
375
|
+
}
|
|
376
|
+
}, children: [
|
|
377
|
+
/* @__PURE__ */ n(f, { sx: {
|
|
378
|
+
display: "flex",
|
|
379
|
+
justifyContent: "center",
|
|
380
|
+
alignItems: "center",
|
|
381
|
+
flexGrow: 1
|
|
382
|
+
}, children: /* @__PURE__ */ n(Q, { maxWidth: "md", children: /* @__PURE__ */ l(p, { container: !0, spacing: 3, children: [
|
|
383
|
+
/* @__PURE__ */ l(p, { item: !0, xs: 12, lg: 5, align: "center", children: [
|
|
384
|
+
/* @__PURE__ */ n("img", { src: e.logo, alt: e.nombre, style: { maxWidth: "100%" } }),
|
|
385
|
+
/* @__PURE__ */ n(T, { variant: "h3", align: "center", children: r("aplicacion.nombre", { smart_count: 1 }) }),
|
|
386
|
+
/* @__PURE__ */ n(T, { variant: "h5", align: "center", children: e.nombre })
|
|
387
|
+
] }),
|
|
388
|
+
/* @__PURE__ */ n(p, { item: !0, xs: 12, lg: 7, sx: {
|
|
389
|
+
display: "flex",
|
|
390
|
+
alignItems: "center",
|
|
391
|
+
justifyContent: "center",
|
|
392
|
+
zIndex: 5
|
|
393
|
+
}, children: /* @__PURE__ */ l(Z, { elevation: 5, children: [
|
|
394
|
+
/* @__PURE__ */ n(J, { title: r("saas.login.titulo"), titleTypographyProps: { align: "center" } }),
|
|
395
|
+
/* @__PURE__ */ n(K, { sx: {
|
|
396
|
+
"& .MuiTextField-root": {
|
|
397
|
+
mb: 2
|
|
398
|
+
}
|
|
399
|
+
}, children: /* @__PURE__ */ n(Me, { devURL: o }) })
|
|
400
|
+
] }) })
|
|
401
|
+
] }) }) }),
|
|
402
|
+
/* @__PURE__ */ n(V, { position: "static", color: "primary", children: /* @__PURE__ */ n(X, { sx: { justifyContent: "center" }, children: /* @__PURE__ */ l(T, { variant: "caption", children: [
|
|
403
|
+
r("saas.copy"),
|
|
404
|
+
/* @__PURE__ */ n(Y, { href: "//chimera.com.pe", color: "inherit", target: "_blank", rel: "noreferrer", children: "Chimera Software" })
|
|
405
|
+
] }) }) })
|
|
406
|
+
] });
|
|
407
|
+
}, He = ({ devURL: o, redirectTo: e, children: r }) => {
|
|
408
|
+
const i = _();
|
|
409
|
+
return G(o) ? r : /* @__PURE__ */ n($, { to: e, state: { from: i }, replace: !0 });
|
|
410
|
+
}, Oe = ({ devURL: o, requiereLogin: e, children: r }) => /* @__PURE__ */ n(fe, { children: /* @__PURE__ */ l(he, { children: [
|
|
411
|
+
/* @__PURE__ */ n(I, { path: "/login", element: /* @__PURE__ */ n(Ue, { devURL: o }) }),
|
|
412
|
+
/* @__PURE__ */ n(
|
|
413
|
+
I,
|
|
414
|
+
{
|
|
415
|
+
path: "/*",
|
|
416
|
+
element: e ? /* @__PURE__ */ n(He, { devURL: o, redirectTo: "/login", children: r }) : r
|
|
417
|
+
}
|
|
418
|
+
)
|
|
419
|
+
] }) }), We = ({ devURL: o, children: e }) => {
|
|
420
|
+
const r = d((i) => i.aplicacion);
|
|
421
|
+
return /* @__PURE__ */ n(f, { sx: {
|
|
422
|
+
display: "flex",
|
|
423
|
+
flexDirection: "column",
|
|
424
|
+
minHeight: "100vh",
|
|
425
|
+
justifyContent: "flex-start",
|
|
426
|
+
backgroundColor: "background.default"
|
|
427
|
+
}, children: r.inicializando ? /* @__PURE__ */ n(ke, {}) : r.error || !r.inicializado ? /* @__PURE__ */ n(F, { titulo: "saas.inicializar.error.titulo", texto: "saas.inicializar.error.mensaje" }) : /* @__PURE__ */ l(M, { children: [
|
|
428
|
+
/* @__PURE__ */ n(Oe, { devURL: o, requiereLogin: r.instancia.requiereLogin, children: e }),
|
|
429
|
+
/* @__PURE__ */ n($e, {})
|
|
430
|
+
] }) });
|
|
431
|
+
}, Qe = ({
|
|
432
|
+
aplicacion: o,
|
|
433
|
+
devSaasURL: e,
|
|
434
|
+
devAuthURL: r,
|
|
435
|
+
messages: i,
|
|
436
|
+
idioma: a,
|
|
437
|
+
children: t
|
|
438
|
+
}) => {
|
|
439
|
+
const c = u();
|
|
440
|
+
return m(() => {
|
|
441
|
+
c(x({ devURL: e, aplicacion: o }));
|
|
442
|
+
}, [c, o, e]), /* @__PURE__ */ n(qe, { messages: i, idioma: a, children: /* @__PURE__ */ n(Ge, { children: /* @__PURE__ */ n(We, { devURL: r, children: t }) }) });
|
|
443
|
+
}, pr = ({
|
|
444
|
+
customReducers: o,
|
|
445
|
+
aplicacion: e,
|
|
446
|
+
devSaasURL: r,
|
|
447
|
+
devAuthURL: i,
|
|
448
|
+
dev: a = !1,
|
|
449
|
+
idioma: t,
|
|
450
|
+
messages: c,
|
|
451
|
+
children: b
|
|
452
|
+
}) => /* @__PURE__ */ n(oe, { store: _e(o), children: /* @__PURE__ */ n(
|
|
453
|
+
Qe,
|
|
454
|
+
{
|
|
455
|
+
aplicacion: e,
|
|
456
|
+
devSaasURL: a && r,
|
|
457
|
+
devAuthURL: a && i,
|
|
458
|
+
idioma: t,
|
|
459
|
+
messages: c,
|
|
460
|
+
children: b
|
|
461
|
+
}
|
|
462
|
+
) });
|
|
463
|
+
export {
|
|
464
|
+
ke as Cargando,
|
|
465
|
+
F as Error,
|
|
466
|
+
pr as SaasApp,
|
|
467
|
+
ze as logout,
|
|
468
|
+
Ee as useNotificar
|
|
469
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(c,i){typeof exports=="object"&&typeof module<"u"?i(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("@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","@mui/material/styles","@mui/material/colors","react-router-dom","@mui/icons-material","react-final-form","mui-rff"],i):(c=typeof globalThis<"u"?globalThis:c||self,i(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.MuiMaterialStyles,c.MuiMaterialColors,c.ReactRouterDom,c.MuiIconsMaterial,c.ReactFinalForm,c.MUIRFF))})(this,function(c,i,s,g,y,l,f,S,G,p,b,N,$,j,v,h,q,P,z){"use strict";const I=()=>i.jsx(s.Box,{sx:{display:"flex",flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:"center"},children:i.jsx(s.CircularProgress,{})}),C=({titulo:o,texto:e,align:r="center",severity:n="error"})=>{const a=g.useTranslate();return i.jsx(s.Box,{sx:{display:"flex",flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:r},children:i.jsxs(s.Alert,{severity:n,children:[i.jsx(s.AlertTitle,{children:a(o)}),e&&a(e)]})})};C.propTypes={titulo:y.string.isRequired,texto:y.string,align:y.string,severity:y.string};const D=f.createSlice({name:"ui",initialState:{tema:"light",temaSeleccionado:!1,idioma:"es"},reducers:{cambiarTema:(o,e)=>{o.tema=e.payload,o.temaSeleccionado=!0,localStorage.setItem("tema",e.payload)},cambiarIdioma:(o,e)=>{o.idioma=e.payload}}}),{cambiarTema:U,cambiarIdioma:H}=D.actions,O=D.reducer,W="https://saas.chimera.com.pe/backend",X="https://saas.chimera.com.pe/oauth",L=(o=X)=>({login:(e,r)=>S({url:`${o}/oauth/token`,headers:{"content-type":"application/x-www-form-urlencoded",Authorization:`Basic ${e}`},method:"post",data:{username:r.correo,password:r.password,grant_type:"password"}}),refreshToken:(e,r)=>S({url:`${o}/oauth/token`,headers:{"content-type":"application/x-www-form-urlencoded",Authorization:`Basic ${e}`},method:"post",data:{refresh_token:r,grant_type:"refresh_token"}})}),F=f.createSlice({name:"login",initialState:{cargando:!1,autenticado:!1,token:null,refreshToken:null,expiracion:null,usuario:null,perfiles:[],error:null},reducers:{logout:o=>{o.cargando=!1,o.autenticado=!1,o.token=null,o.refreshToken=null,o.expiracion=null,o.usuario=null,o.perfiles=[],o.error=null}},extraReducers(o){o.addCase(m.pending,e=>{e.cargando=!0,e.error=null}).addCase(m.fulfilled,(e,r)=>{const n=r.payload.access_token,a=G(n),t=new Date;t.setSeconds(t.getSeconds()+r.payload.expires_in),e.cargando=!1,e.autenticado=!0,e.token=n,e.refreshToken=r.payload.refresh_token,e.expiracion=t.getTime(),e.usuario=a.name,e.perfiles=a.authorities}).addCase(m.rejected,(e,r)=>{var n;console.log(r),e.cargando=!1,e.autenticado=!1,e.token=null,e.refreshToken=null,e.expiracion=null,e.usuario=null,e.perfiles=[],e.error=(n=r.error)==null?void 0:n.message}).addCase(k.pending,e=>{e.cargando=!0}).addCase(k.fulfilled,(e,r)=>{const n=new Date;n.setSeconds(n.getSeconds()+r.payload.expires_in),e.token=r.payload.access_token,e.refreshToken=r.payload.refresh_token,e.expiracion=n.getTime()}).addCase(k.rejected,(e,r)=>{var n;e.cargando=!1,e.autenticado=!1,e.token=null,e.refreshToken=null,e.expiracion=null,e.usuario=null,e.perfiles=[],e.error=(n=r.error)==null?void 0:n.message})}}),m=f.createAsyncThunk("login/requestToken",async o=>(await L(o.devURL).login(o.clientCredentials,o.data)).data),k=f.createAsyncThunk("login/refreshToken",async(o,e,r)=>(await L(o).refreshToken(e,r)).data),{logout:M}=F.actions,J=F.reducer,B=f.createSlice({name:"notificacion",initialState:[],reducers:{mostrarNotificacion:(o,e)=>{o.push(e.payload)},ocultarNotificacion:o=>{o.pop()}}}),{mostrarNotificacion:Q,ocultarNotificacion:Z}=B.actions,K=B.reducer,V=(o=W,e)=>S({url:`${o}/identidad/`,params:{codigoAplicacion:e}}),T={primary:"#1C6CCC",secondary:"#17A7FF",error:"#f44336",warning:"#ff9800",info:"#2196f3",success:"#4caf50"},Y=f.createSlice({name:"inicializar",initialState:{inicializando:!0,inicializado:!1,instancia:{color:T},error:null},extraReducers(o){o.addCase(x.pending,e=>{e.inicializando=!0}).addCase(x.fulfilled,(e,r)=>{e.inicializando=!1,e.inicializado=!0,e.instancia={...r.payload,abreviatura:r.payload.nombre.match(/\b([A-Z])/g).join(""),color:{...T,...r.payload.color}},e.error=null}).addCase(x.rejected,(e,r)=>{e.inicializando=!1,e.inicializado=!1,e.instancia={color:T},e.error=r.payload})}}),x=f.createAsyncThunk("inicializar",async o=>(await V(o.devURL,o.aplicacion)).data),R=Y.reducer,ee=o=>f.configureStore({reducer:{ui:O,aplicacion:R,login:J,notificaciones:K,...o}}),re=()=>{const[o,e]=p.useState(!1),r=l.useDispatch(),n=g.useTranslate(),a=l.useSelector(d=>d.notificaciones[0]);p.useEffect(()=>{e(!!a)},[a]);const t=()=>{e(!1),r(Z())};return i.jsx(s.Snackbar,{open:o,message:a&&a.mensaje&&a.tipo==="default"&&n(a.mensaje),autoHideDuration:5e3,onClose:t,children:a&&a.mensaje&&a.tipo!=="default"&&i.jsx(s.Alert,{severity:a.tipo,children:n(a.mensaje)})})},oe={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 "}},ie={en:b.enGB,es:b.es},ne=({messages:o,children:e})=>{const r=l.useSelector(n=>n.ui.idioma);return i.jsx(g.I18n,{locale:r,messages:o[r],children:i.jsx(N.LocalizationProvider,{dateAdapter:$.AdapterDateFns,adapterLocale:ie[r],children:e})})},ae=({messages:o,idioma:e,children:r})=>{const n=l.useDispatch();p.useEffect(()=>{e&&n(H(e))},[n,e]);const a={};return Object.keys(o).forEach(t=>{a[t]={...o[t],saas:oe[t]}}),i.jsx(ne,{messages:a,children:r})},se=({children:o})=>{const e=l.useDispatch(),{instancia:r}=l.useSelector(d=>d.aplicacion),n=l.useSelector(d=>d.ui.tema),a=s.useMediaQuery("(prefers-color-scheme: dark)");p.useEffect(()=>{e(U(a?"dark":"light"))},[e,a]);const t=p.useMemo(()=>j.createTheme({palette:{mode:n,primary:{main:r.color.primary},secondary:{main:r.color.secondary},error:{main:r.color.error},warning:{main:r.color.warning},info:{main:r.color.info},success:{main:r.color.success},...n==="light"&&{background:{default:v.grey.A200,paper:v.grey[100]}}},shape:{borderRadius:6}}),[n,r]);return i.jsxs(j.ThemeProvider,{theme:t,children:[i.jsx(s.CssBaseline,{}),o]})},_=o=>{const e=l.useDispatch(),r=l.useSelector(a=>a.login),n=l.useSelector(a=>a.aplicacion.instancia);return p.useEffect(()=>{r.autenticado&&r.expiracion&&new Date(r.expiracion)<new Date&&(r.refreshToken?e(k(o,n.clientCredentials,r.refreshToken)):e(M()))},[o,n.clientCredentials,r,e]),r.autenticado},E=()=>{const o=l.useDispatch();return p.useCallback((e,r="default")=>{o(Q({mensaje:e,tipo:r}))},[o])},ce=({devURL:o})=>{const e=l.useDispatch(),r=g.useTranslate(),n=E(),{cargando:a,error:t}=l.useSelector(u=>u.login),d=l.useSelector(u=>u.aplicacion.instancia),w=u=>{e(m({devURL:o,clientCredentials:d.clientCredentials,data:{correo:u.correo,password:u.password}}))},he=u=>{const A={correo:void 0,password:void 0};return u.correo||(A.correo=r("saas.login.validacion.correo")),u.password||(A.password=r("saas.login.validacion.password")),A};return p.useEffect(()=>{t&&n("saas.login.error","error")},[n,t]),i.jsx(P.Form,{onSubmit:w,validate:he,render:({handleSubmit:u})=>i.jsxs("form",{onSubmit:u,children:[i.jsx(z.TextField,{id:"correo",name:"correo",label:r("saas.login.correo"),variant:"outlined",autoComplete:"off",disabled:a,autoFocus:!0,InputProps:{startAdornment:i.jsx(s.InputAdornment,{position:"start",children:i.jsx(q.Email,{color:"primary"})})}}),i.jsx(z.TextField,{id:"password",name:"password",type:"password",label:r("saas.login.password"),variant:"outlined",autoComplete:"current-password",disabled:a,InputProps:{startAdornment:i.jsx(s.InputAdornment,{position:"start",children:i.jsx(q.Lock,{color:"primary"})})}}),i.jsxs(s.Grid,{container:!0,children:[i.jsx(s.Grid,{item:!0,xs:6}),i.jsx(s.Grid,{item:!0,xs:6,align:"right",children:i.jsx(s.Button,{variant:"contained",color:"primary",type:"submit",disabled:a,children:a?i.jsx(s.CircularProgress,{size:24,thickness:4}):r("saas.login.ingresar")})})]})]})})},te=({devURL:o})=>{const e=l.useSelector(d=>d.aplicacion.instancia),r=g.useTranslate(),n=h.useLocation(),a=_(o),{from:t}=n.state||{from:{pathname:"/"}};return!e.requiereLogin||a?i.jsx(h.Navigate,{to:t}):i.jsxs(s.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:[i.jsx(s.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",flexGrow:1},children:i.jsx(s.Container,{maxWidth:"md",children:i.jsxs(s.Grid,{container:!0,spacing:3,children:[i.jsxs(s.Grid,{item:!0,xs:12,lg:5,align:"center",children:[i.jsx("img",{src:e.logo,alt:e.nombre,style:{maxWidth:"100%"}}),i.jsx(s.Typography,{variant:"h3",align:"center",children:r("aplicacion.nombre",{smart_count:1})}),i.jsx(s.Typography,{variant:"h5",align:"center",children:e.nombre})]}),i.jsx(s.Grid,{item:!0,xs:12,lg:7,sx:{display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:i.jsxs(s.Card,{elevation:5,children:[i.jsx(s.CardHeader,{title:r("saas.login.titulo"),titleTypographyProps:{align:"center"}}),i.jsx(s.CardContent,{sx:{"& .MuiTextField-root":{mb:2}},children:i.jsx(ce,{devURL:o})})]})})]})})}),i.jsx(s.AppBar,{position:"static",color:"primary",children:i.jsx(s.Toolbar,{sx:{justifyContent:"center"},children:i.jsxs(s.Typography,{variant:"caption",children:[r("saas.copy"),i.jsx(s.Link,{href:"//chimera.com.pe",color:"inherit",target:"_blank",rel:"noreferrer",children:"Chimera Software"})]})})})]})},le=({devURL:o,redirectTo:e,children:r})=>{const n=h.useLocation();return _(o)?r:i.jsx(h.Navigate,{to:e,state:{from:n},replace:!0})},de=({devURL:o,requiereLogin:e,children:r})=>i.jsx(h.BrowserRouter,{children:i.jsxs(h.Routes,{children:[i.jsx(h.Route,{path:"/login",element:i.jsx(te,{devURL:o})}),i.jsx(h.Route,{path:"/*",element:e?i.jsx(le,{devURL:o,redirectTo:"/login",children:r}):r})]})}),ue=({devURL:o,children:e})=>{const r=l.useSelector(n=>n.aplicacion);return i.jsx(s.Box,{sx:{display:"flex",flexDirection:"column",minHeight:"100vh",justifyContent:"flex-start",backgroundColor:"background.default"},children:r.inicializando?i.jsx(I,{}):r.error||!r.inicializado?i.jsx(C,{titulo:"saas.inicializar.error.titulo",texto:"saas.inicializar.error.mensaje"}):i.jsxs(i.Fragment,{children:[i.jsx(de,{devURL:o,requiereLogin:r.instancia.requiereLogin,children:e}),i.jsx(re,{})]})})},pe=({aplicacion:o,devSaasURL:e,devAuthURL:r,messages:n,idioma:a,children:t})=>{const d=l.useDispatch();return p.useEffect(()=>{d(x({devURL:e,aplicacion:o}))},[d,o,e]),i.jsx(ae,{messages:n,idioma:a,children:i.jsx(se,{children:i.jsx(ue,{devURL:r,children:t})})})},fe=({customReducers:o,aplicacion:e,devSaasURL:r,devAuthURL:n,dev:a=!1,idioma:t,messages:d,children:w})=>i.jsx(l.Provider,{store:ee(o),children:i.jsx(pe,{aplicacion:e,devSaasURL:a&&r,devAuthURL:a&&n,idioma:t,messages:d,children:w})});c.Cargando=I,c.Error=C,c.SaasApp=fe,c.logout=M,c.useNotificar=E,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chimera-pe/react-saas",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"private": false,
|
|
3
|
+
"version": "0.0.3",
|
|
5
4
|
"type": "module",
|
|
6
5
|
"scripts": {
|
|
7
6
|
"dev": "vite",
|
|
@@ -9,44 +8,52 @@
|
|
|
9
8
|
"lint": "eslint src --ext js,jsx --report-unused-disable-directives --max-warnings 0",
|
|
10
9
|
"preview": "vite preview"
|
|
11
10
|
},
|
|
12
|
-
"
|
|
13
|
-
"@reduxjs/toolkit": ">=1.9",
|
|
14
|
-
"react": ">=18"
|
|
15
|
-
},
|
|
16
|
-
"devDependencies": {
|
|
11
|
+
"dependencies": {
|
|
17
12
|
"@emotion/react": "^11.11.1",
|
|
18
13
|
"@emotion/styled": "^11.11.0",
|
|
19
14
|
"@mui/icons-material": "^5.14.1",
|
|
20
15
|
"@mui/lab": "^5.0.0-alpha.137",
|
|
21
16
|
"@mui/material": "^5.14.1",
|
|
17
|
+
"@mui/x-date-pickers": "^6.10.1",
|
|
22
18
|
"@reduxjs/toolkit": "^1.9.5",
|
|
19
|
+
"axios": "^1.4.0",
|
|
20
|
+
"date-fns": "^2.30.0",
|
|
21
|
+
"final-form": "^4.20.9",
|
|
22
|
+
"jwt-decode": "^3.1.2",
|
|
23
|
+
"mui-rff": "^6.2.0",
|
|
24
|
+
"react": ">=18",
|
|
25
|
+
"react-dom": ">=18",
|
|
26
|
+
"react-final-form": "^6.5.9",
|
|
27
|
+
"react-polyglot": "^0.7.2",
|
|
28
|
+
"react-redux": "^8.1.1",
|
|
29
|
+
"react-router-dom": "^6.14.2"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"react": ">=18",
|
|
33
|
+
"react-dom": ">=18"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
23
36
|
"@types/react": "^18.2.14",
|
|
24
37
|
"@types/react-dom": "^18.2.6",
|
|
25
38
|
"@vitejs/plugin-react": "^4.0.1",
|
|
26
|
-
"axios": "^1.4.0",
|
|
27
|
-
"date-fns": "^2.30.0",
|
|
28
39
|
"eslint": "^8.44.0",
|
|
29
40
|
"eslint-plugin-react": "^7.32.2",
|
|
30
41
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
31
42
|
"eslint-plugin-react-refresh": "^0.4.1",
|
|
32
|
-
"jwt-decode": "^3.1.2",
|
|
33
|
-
"mui-rff": "^6.1.4",
|
|
34
|
-
"react": "^18.2.0",
|
|
35
|
-
"react-dom": "^18.2.0",
|
|
36
|
-
"react-polyglot": "^0.7.2",
|
|
37
|
-
"react-redux": "^8.1.1",
|
|
38
|
-
"react-router-dom": "^6.14.2",
|
|
39
43
|
"vite": "^4.4.0"
|
|
40
44
|
},
|
|
41
45
|
"description": "Componente integrador con SaaS",
|
|
42
|
-
"main": "./dist/react-saas.umd.
|
|
43
|
-
"module": "./dist/react-saas.
|
|
46
|
+
"main": "./dist/react-saas.umd.cjs",
|
|
47
|
+
"module": "./dist/react-saas.js",
|
|
44
48
|
"exports": {
|
|
45
49
|
".": {
|
|
46
|
-
"import": "./dist/react-saas.
|
|
47
|
-
"
|
|
50
|
+
"import": "./dist/react-saas.js",
|
|
51
|
+
"require": "./dist/react-saas.umd.cjs"
|
|
48
52
|
}
|
|
49
53
|
},
|
|
54
|
+
"files": [
|
|
55
|
+
"dist"
|
|
56
|
+
],
|
|
50
57
|
"repository": {
|
|
51
58
|
"type": "git",
|
|
52
59
|
"url": "https://git.chimera.com.pe/chimera/react-saas.git"
|
package/.eslintrc.cjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/* eslint-env node */
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
env: { browser: true, es2020: true },
|
|
5
|
-
extends: [
|
|
6
|
-
'eslint:recommended',
|
|
7
|
-
'plugin:react/recommended',
|
|
8
|
-
'plugin:react/jsx-runtime',
|
|
9
|
-
'plugin:react-hooks/recommended',
|
|
10
|
-
],
|
|
11
|
-
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
|
|
12
|
-
settings: { react: { version: '18.2' } },
|
|
13
|
-
plugins: ['react-refresh'],
|
|
14
|
-
rules: {
|
|
15
|
-
'react-refresh/only-export-components': [
|
|
16
|
-
'warn',
|
|
17
|
-
{ allowConstantExport: true },
|
|
18
|
-
],
|
|
19
|
-
},
|
|
20
|
-
}
|
package/src/Constantes.js
DELETED
package/src/api/loginApi.jsx
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import {authURL} from "../Constantes";
|
|
3
|
-
|
|
4
|
-
export const loginApi = (url = authURL) => ({
|
|
5
|
-
login: (clientCredentials,data) => axios({
|
|
6
|
-
url: `${url}/oauth/token`,
|
|
7
|
-
headers: {
|
|
8
|
-
"content-type": "application/x-www-form-urlencoded",
|
|
9
|
-
Authorization: `Basic ${clientCredentials}`
|
|
10
|
-
},
|
|
11
|
-
method: "post",
|
|
12
|
-
data: {
|
|
13
|
-
username: data.correo,
|
|
14
|
-
password: data.password,
|
|
15
|
-
"grant_type": "password"
|
|
16
|
-
}
|
|
17
|
-
}),
|
|
18
|
-
refreshToken: (clientCredentials,refreshToken) => axios({
|
|
19
|
-
url: `${url}/oauth/token`,
|
|
20
|
-
headers: {
|
|
21
|
-
"content-type": "application/x-www-form-urlencoded",
|
|
22
|
-
Authorization: `Basic ${clientCredentials}`
|
|
23
|
-
},
|
|
24
|
-
method: "post",
|
|
25
|
-
data: {
|
|
26
|
-
"refresh_token": refreshToken,
|
|
27
|
-
"grant_type": "refresh_token"
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {Box,CircularProgress} from "@mui/material";
|
|
2
|
-
|
|
3
|
-
const Cargando=() => (
|
|
4
|
-
<Box sx={{
|
|
5
|
-
display: "flex",
|
|
6
|
-
flexDirection: "column",
|
|
7
|
-
flexGrow: 1,
|
|
8
|
-
justifyContent: "center",
|
|
9
|
-
alignItems: "center"
|
|
10
|
-
}}>
|
|
11
|
-
<CircularProgress />
|
|
12
|
-
</Box>
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
export default Cargando;
|