react-ecosistema-unp 1.8.0-pre.2 → 1.8.0-pre.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/contexts/AuthContex.js +12 -14
- package/dist/auth/hooks/useFinalizarSesion.js +5 -5
- package/dist/lib/auth/contexts/AuthContex.d.ts +0 -3
- package/dist/shared/app-list/AppList.js +7 -7
- package/dist/shared/menu-lateral/MenuLateral.js +9 -9
- package/dist/utils/components/ProtectedRoute.js +14 -20
- package/package.json +1 -1
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
const
|
|
4
|
-
const [o, r] =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// localStorage.getItem("user_token")
|
|
9
|
-
""
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as u, useState as t } from "react";
|
|
3
|
+
const c = u(void 0), i = ({ children: e }) => {
|
|
4
|
+
const [o, r] = t(
|
|
5
|
+
localStorage.getItem("access_token")
|
|
6
|
+
), [n, s] = t(
|
|
7
|
+
localStorage.getItem("auth_state")
|
|
10
8
|
);
|
|
11
|
-
return /* @__PURE__ */
|
|
12
|
-
|
|
9
|
+
return /* @__PURE__ */ a(
|
|
10
|
+
c.Provider,
|
|
13
11
|
{
|
|
14
12
|
value: { authToken: o, setAuthToken: r, userToken: n, setUserToken: s },
|
|
15
|
-
children:
|
|
13
|
+
children: e
|
|
16
14
|
}
|
|
17
15
|
);
|
|
18
16
|
};
|
|
19
17
|
export {
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
c as AuthContext,
|
|
19
|
+
i as AuthProvider
|
|
22
20
|
};
|
|
@@ -3,23 +3,23 @@ import { y as a } from "../../index-BUe3EJDH.js";
|
|
|
3
3
|
import { useState as c, useEffect as l } from "react";
|
|
4
4
|
import { j as m } from "../../index-CuHybtft.js";
|
|
5
5
|
const d = () => {
|
|
6
|
-
const [o,
|
|
6
|
+
const [o, r] = c(null), n = `${window.location.protocol}//${window.location.host}/`;
|
|
7
7
|
return l(() => {
|
|
8
|
-
const e = localStorage.getItem("
|
|
8
|
+
const e = localStorage.getItem("access_token");
|
|
9
9
|
if (e) {
|
|
10
10
|
const t = m(e);
|
|
11
|
-
|
|
11
|
+
r(t);
|
|
12
12
|
}
|
|
13
13
|
}, []), { FinSesion: () => {
|
|
14
14
|
a.promise(
|
|
15
15
|
new Promise(async (e, t) => {
|
|
16
16
|
try {
|
|
17
|
-
await i((o == null ? void 0 : o.user.username) || "",
|
|
17
|
+
await i((o == null ? void 0 : o.user.username) || "", n), e(!0);
|
|
18
18
|
} catch (s) {
|
|
19
19
|
t(s);
|
|
20
20
|
} finally {
|
|
21
21
|
sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), setTimeout(() => {
|
|
22
|
-
window.location.href =
|
|
22
|
+
window.location.href = n;
|
|
23
23
|
}, 1e3);
|
|
24
24
|
}
|
|
25
25
|
}),
|
|
@@ -4,8 +4,5 @@ declare const AuthContext: React.Context<AuthContextType | undefined>;
|
|
|
4
4
|
interface AuthProviderProps {
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated since version 1.7.7 — use `EcoProvider` instead.
|
|
9
|
-
*/
|
|
10
7
|
declare const AuthProvider: React.FC<AuthProviderProps>;
|
|
11
8
|
export { AuthContext, AuthProvider };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as o, jsxs as r } from "react/jsx-runtime";
|
|
2
2
|
import { useState as d, useEffect as h } from "react";
|
|
3
|
-
import { F as
|
|
3
|
+
import { F as t, f as u, g as f, h as v, i as z } from "../../index-D3WseyJh.js";
|
|
4
4
|
import { z as N } from "../../index-DDjnZyBf.js";
|
|
5
5
|
import { G as g } from "../../iconBase-LROS5hdG.js";
|
|
6
6
|
import { j as w } from "../../index-CuHybtft.js";
|
|
@@ -9,7 +9,7 @@ import '../../assets/AppList.css';function b(s) {
|
|
|
9
9
|
return g({ tag: "svg", attr: { fill: "currentColor", viewBox: "0 0 16 16" }, child: [{ tag: "path", attr: { d: "M1 2a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1zM1 7a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1zM1 12a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1z" }, child: [] }] })(s);
|
|
10
10
|
}
|
|
11
11
|
const F = {
|
|
12
|
-
Usuario: /* @__PURE__ */ o(
|
|
12
|
+
Usuario: /* @__PURE__ */ o(t, { size: 24, className: "icon-app-2" }),
|
|
13
13
|
"Asesor(a) poblacional": /* @__PURE__ */ o(u, { size: 24, className: "icon-app-2" }),
|
|
14
14
|
Radicador: /* @__PURE__ */ o(f, { size: 24, className: "icon-app-2" }),
|
|
15
15
|
"Reparto poblacional": /* @__PURE__ */ o(v, { size: 24, className: "icon-app-2" }),
|
|
@@ -23,7 +23,7 @@ const F = {
|
|
|
23
23
|
}, j = () => {
|
|
24
24
|
const [s, l] = d([]), e = location.pathname, c = e.startsWith("/") ? e : `/${e}`;
|
|
25
25
|
h(() => {
|
|
26
|
-
const a = localStorage.getItem("
|
|
26
|
+
const a = localStorage.getItem("access_token");
|
|
27
27
|
if (a)
|
|
28
28
|
try {
|
|
29
29
|
const i = w(a);
|
|
@@ -32,7 +32,7 @@ const F = {
|
|
|
32
32
|
console.error("Error al decodificar el token:", i);
|
|
33
33
|
}
|
|
34
34
|
}, []);
|
|
35
|
-
const
|
|
35
|
+
const n = (a) => {
|
|
36
36
|
const i = `${window.location.protocol}//${window.location.host}/${a}`;
|
|
37
37
|
window.location.href = i;
|
|
38
38
|
};
|
|
@@ -51,7 +51,7 @@ const F = {
|
|
|
51
51
|
"div",
|
|
52
52
|
{
|
|
53
53
|
className: `icon-wrapper ${c === "/" + i ? "active" : ""}`,
|
|
54
|
-
onClick: () =>
|
|
54
|
+
onClick: () => n(i),
|
|
55
55
|
children: [
|
|
56
56
|
p,
|
|
57
57
|
/* @__PURE__ */ o("span", { className: "icono-nombre-app", children: m })
|
|
@@ -64,9 +64,9 @@ const F = {
|
|
|
64
64
|
"div",
|
|
65
65
|
{
|
|
66
66
|
className: `icon-wrapper ${c === "/unp/ecosistema/usuario" ? "active" : ""}`,
|
|
67
|
-
onClick: () =>
|
|
67
|
+
onClick: () => n("unp/ecosistema/usuario"),
|
|
68
68
|
children: [
|
|
69
|
-
/* @__PURE__ */ o(
|
|
69
|
+
/* @__PURE__ */ o(t, { size: 24, className: "icon-app-2" }),
|
|
70
70
|
/* @__PURE__ */ o("span", { className: "icono-nombre-app", children: "Mi Perfil" })
|
|
71
71
|
]
|
|
72
72
|
},
|
|
@@ -68,10 +68,10 @@ function G(t) {
|
|
|
68
68
|
function W(t) {
|
|
69
69
|
return i({ tag: "svg", attr: { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { d: "M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z" }, child: [] }] })(t);
|
|
70
70
|
}
|
|
71
|
-
const z1 = ({ onToggle: t, isOpen:
|
|
72
|
-
const [N, f] = o(!0), [m, p] = o(null), k =
|
|
71
|
+
const z1 = ({ onToggle: t, isOpen: c, showConnectionStatus: x }) => {
|
|
72
|
+
const [N, f] = o(!0), [m, p] = o(null), k = c ? "sidebar-bar-panel open" : "sidebar-bar-panel", w = H(), { FinSesion: b } = C(), { connectionStatus: v } = A(), [z, l] = o(!1), [M, n] = o(""), h = `${window.location.host}`;
|
|
73
73
|
if (d(() => {
|
|
74
|
-
const r = localStorage.getItem("
|
|
74
|
+
const r = localStorage.getItem("access_token");
|
|
75
75
|
if (r) {
|
|
76
76
|
const s = u(r);
|
|
77
77
|
p(s);
|
|
@@ -79,7 +79,7 @@ const z1 = ({ onToggle: t, isOpen: l, showConnectionStatus: x }) => {
|
|
|
79
79
|
f(!1);
|
|
80
80
|
}, []), d(() => {
|
|
81
81
|
const r = setTimeout(() => {
|
|
82
|
-
const s = localStorage.getItem("
|
|
82
|
+
const s = localStorage.getItem("access_token");
|
|
83
83
|
if (s) {
|
|
84
84
|
const _ = u(s);
|
|
85
85
|
p(_);
|
|
@@ -87,13 +87,13 @@ const z1 = ({ onToggle: t, isOpen: l, showConnectionStatus: x }) => {
|
|
|
87
87
|
}, 2e3);
|
|
88
88
|
return () => clearTimeout(r);
|
|
89
89
|
}, []), d(() => {
|
|
90
|
-
h.includes("localhost") ? (
|
|
90
|
+
h.includes("localhost") ? (l(!0), n("Entorno local")) : h.includes("ecosistemadesarrollo") ? (l(!0), n("Entorno de desarrollo")) : h.includes("ecosistemapruebas") ? (l(!0), n("Entorno de pruebas")) : (l(!1), n(""));
|
|
91
91
|
}, []), N)
|
|
92
92
|
return /* @__PURE__ */ a(g, {});
|
|
93
93
|
const B = () => {
|
|
94
94
|
w("/unp/ecosistema/usuario");
|
|
95
95
|
};
|
|
96
|
-
return /* @__PURE__ */ a("div", { className: `container-fluid ${
|
|
96
|
+
return /* @__PURE__ */ a("div", { className: `container-fluid ${c ? "menu-open" : ""}`, children: /* @__PURE__ */ e("div", { className: k, children: [
|
|
97
97
|
/* @__PURE__ */ e("div", { className: "logo_details", children: [
|
|
98
98
|
/* @__PURE__ */ a(
|
|
99
99
|
"img",
|
|
@@ -104,7 +104,7 @@ const z1 = ({ onToggle: t, isOpen: l, showConnectionStatus: x }) => {
|
|
|
104
104
|
}
|
|
105
105
|
),
|
|
106
106
|
/* @__PURE__ */ a("div", { className: "logo-name", children: "EI - UNP" }),
|
|
107
|
-
|
|
107
|
+
c ? /* @__PURE__ */ a(
|
|
108
108
|
$,
|
|
109
109
|
{
|
|
110
110
|
className: "bx bx-menu i",
|
|
@@ -195,7 +195,7 @@ const z1 = ({ onToggle: t, isOpen: l, showConnectionStatus: x }) => {
|
|
|
195
195
|
] })
|
|
196
196
|
] }),
|
|
197
197
|
/* @__PURE__ */ e("div", { className: "profile-content", children: [
|
|
198
|
-
!
|
|
198
|
+
!c && x && /* @__PURE__ */ a(g, { children: v === "connected" ? /* @__PURE__ */ e("div", { className: "gear-tooltip-container", children: [
|
|
199
199
|
/* @__PURE__ */ e(
|
|
200
200
|
"svg",
|
|
201
201
|
{
|
|
@@ -257,7 +257,7 @@ const z1 = ({ onToggle: t, isOpen: l, showConnectionStatus: x }) => {
|
|
|
257
257
|
]
|
|
258
258
|
}
|
|
259
259
|
) }),
|
|
260
|
-
!
|
|
260
|
+
!c && z && /* @__PURE__ */ e("div", { className: "gear-tooltip-container", children: [
|
|
261
261
|
/* @__PURE__ */ a(
|
|
262
262
|
"svg",
|
|
263
263
|
{
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { useLocation as
|
|
1
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import { useState as g, useEffect as S } from "react";
|
|
3
|
+
import { useLocation as I, Outlet as _ } from "react-router-dom";
|
|
4
4
|
import { j as u } from "../../index-CuHybtft.js";
|
|
5
|
-
const
|
|
6
|
-
const [
|
|
5
|
+
const W = () => {
|
|
6
|
+
const [k, o] = g(!1), m = I(), s = `${window.location.protocol}//${window.location.host}/`, n = `${window.location.host}`, w = async () => {
|
|
7
7
|
if ((await fetch(`${s}api-auth/auth/refresh_token/`, {
|
|
8
8
|
method: "POST",
|
|
9
9
|
headers: {
|
|
@@ -14,19 +14,13 @@ const y = () => {
|
|
|
14
14
|
return !0;
|
|
15
15
|
throw new Error("Error al refrescar token de Microsoft");
|
|
16
16
|
};
|
|
17
|
-
return
|
|
17
|
+
return S(() => {
|
|
18
18
|
const h = async () => {
|
|
19
19
|
try {
|
|
20
|
-
if ((
|
|
21
|
-
|
|
22
|
-
headers: {
|
|
23
|
-
"Content-Type": "application/json"
|
|
24
|
-
},
|
|
25
|
-
credentials: "include"
|
|
26
|
-
})).ok) {
|
|
27
|
-
const c = localStorage.getItem("auth_state");
|
|
20
|
+
if (localStorage.getItem("auth_state")) {
|
|
21
|
+
const c = localStorage.getItem("access_token");
|
|
28
22
|
if (c) {
|
|
29
|
-
const
|
|
23
|
+
const f = u(c).user.servicios.map((e) => e.url).filter((e) => !!e), r = m.pathname, a = f.map(
|
|
30
24
|
(e) => e.startsWith("/") ? e : `/${e}`
|
|
31
25
|
), i = r.startsWith("/") ? r : `/${r}`;
|
|
32
26
|
a.some(
|
|
@@ -39,13 +33,13 @@ const y = () => {
|
|
|
39
33
|
} catch {
|
|
40
34
|
try {
|
|
41
35
|
if (await w()) {
|
|
42
|
-
const l = localStorage.getItem("
|
|
36
|
+
const l = localStorage.getItem("access_token");
|
|
43
37
|
if (l) {
|
|
44
38
|
const r = u(l).user.servicios.map((t) => t.url).filter((t) => !!t), a = m.pathname, i = r.map(
|
|
45
39
|
(t) => t.startsWith("/") ? t : `/${t}`
|
|
46
|
-
),
|
|
40
|
+
), d = a.startsWith("/") ? a : `/${a}`;
|
|
47
41
|
i.some(
|
|
48
|
-
(t) =>
|
|
42
|
+
(t) => d.startsWith(t)
|
|
49
43
|
) ? o(!0) : (o(!1), sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), window.location.href = s);
|
|
50
44
|
} else
|
|
51
45
|
o(!1), sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), window.location.href = s;
|
|
@@ -57,8 +51,8 @@ const y = () => {
|
|
|
57
51
|
}
|
|
58
52
|
};
|
|
59
53
|
n.includes("ecosistemadesarrollo") || n.includes("ecosistemapruebas") || n.includes("ecosistemaprov") || n.includes("ecosistema") ? h() : (console.warn("ProtectedRoute is disabled in the local development environment."), o(!0));
|
|
60
|
-
}, []),
|
|
54
|
+
}, []), k ? /* @__PURE__ */ p(_, {}) : null;
|
|
61
55
|
};
|
|
62
56
|
export {
|
|
63
|
-
|
|
57
|
+
W as ProtectedRoute
|
|
64
58
|
};
|