react-ecosistema-unp 1.8.0-pre.2 → 1.8.0-pre.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.
@@ -1,22 +1,20 @@
1
- import { jsx as u } from "react/jsx-runtime";
2
- import { createContext as c, useState as e } from "react";
3
- const i = c(void 0), h = ({ children: t }) => {
4
- const [o, r] = e(
5
- // localStorage.getItem("access_token")
6
- ""
7
- ), [n, s] = e(
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__ */ u(
12
- i.Provider,
9
+ return /* @__PURE__ */ a(
10
+ c.Provider,
13
11
  {
14
12
  value: { authToken: o, setAuthToken: r, userToken: n, setUserToken: s },
15
- children: t
13
+ children: e
16
14
  }
17
15
  );
18
16
  };
19
17
  export {
20
- i as AuthContext,
21
- h as AuthProvider
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, n] = c(null), r = `${window.location.protocol}//${window.location.host}/`;
6
+ const [o, r] = c(null), n = `${window.location.protocol}//${window.location.host}/`;
7
7
  return l(() => {
8
- const e = localStorage.getItem("auth_state");
8
+ const e = localStorage.getItem("access_token");
9
9
  if (e) {
10
10
  const t = m(e);
11
- n(t);
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) || "", r), e(!0);
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 = r;
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 n, f as u, g as f, h as v, i as z } from "../../index-D3WseyJh.js";
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(n, { size: 24, className: "icon-app-2" }),
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("auth_state");
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 t = (a) => {
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: () => t(i),
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: () => t("unp/ecosistema/usuario"),
67
+ onClick: () => n("unp/ecosistema/usuario"),
68
68
  children: [
69
- /* @__PURE__ */ o(n, { size: 24, className: "icon-app-2" }),
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: l, showConnectionStatus: x }) => {
72
- const [N, f] = o(!0), [m, p] = o(null), k = l ? "sidebar-bar-panel open" : "sidebar-bar-panel", w = H(), { FinSesion: b } = C(), { connectionStatus: v } = A(), [z, c] = o(!1), [M, n] = o(""), h = `${window.location.host}`;
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("auth_state");
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("auth_state");
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") ? (c(!0), n("Entorno local")) : h.includes("ecosistemadesarrollo") ? (c(!0), n("Entorno de desarrollo")) : h.includes("ecosistemapruebas") ? (c(!0), n("Entorno de pruebas")) : (c(!1), n(""));
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 ${l ? "menu-open" : ""}`, children: /* @__PURE__ */ e("div", { className: k, children: [
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
- l ? /* @__PURE__ */ a(
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
- !l && x && /* @__PURE__ */ a(g, { children: v === "connected" ? /* @__PURE__ */ e("div", { className: "gear-tooltip-container", children: [
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
- !l && z && /* @__PURE__ */ e("div", { className: "gear-tooltip-container", children: [
260
+ !c && z && /* @__PURE__ */ e("div", { className: "gear-tooltip-container", children: [
261
261
  /* @__PURE__ */ a(
262
262
  "svg",
263
263
  {
@@ -24,7 +24,7 @@ const y = () => {
24
24
  },
25
25
  credentials: "include"
26
26
  })).ok) {
27
- const c = localStorage.getItem("auth_state");
27
+ const c = localStorage.getItem("access_token");
28
28
  if (c) {
29
29
  const d = u(c).user.servicios.map((e) => e.url).filter((e) => !!e), r = m.pathname, a = d.map(
30
30
  (e) => e.startsWith("/") ? e : `/${e}`
@@ -39,7 +39,7 @@ const y = () => {
39
39
  } catch {
40
40
  try {
41
41
  if (await w()) {
42
- const l = localStorage.getItem("auth_state");
42
+ const l = localStorage.getItem("access_token");
43
43
  if (l) {
44
44
  const r = u(l).user.servicios.map((t) => t.url).filter((t) => !!t), a = m.pathname, i = r.map(
45
45
  (t) => t.startsWith("/") ? t : `/${t}`
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "react-ecosistema-unp",
3
3
  "author": "Ecosistema de Información - Unidad Nacional de Protección",
4
4
  "private": false,
5
- "version": "1.8.0-pre.2",
5
+ "version": "1.8.0-pre.3",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": {