react-ecosistema-unp 1.8.0-pre.4 → 1.8.0-pre.6

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,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 t, f as u, g as f, h as v, i as z } from "../../index-D3WseyJh.js";
3
+ import { F as n, 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(t, { size: 24, className: "icon-app-2" }),
12
+ Usuario: /* @__PURE__ */ o(n, { 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("access_token");
26
+ const a = localStorage.getItem("auth_state");
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 n = (a) => {
35
+ const t = (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: () => n(i),
54
+ onClick: () => t(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: () => n("unp/ecosistema/usuario"),
67
+ onClick: () => t("unp/ecosistema/usuario"),
68
68
  children: [
69
- /* @__PURE__ */ o(t, { size: 24, className: "icon-app-2" }),
69
+ /* @__PURE__ */ o(n, { size: 24, className: "icon-app-2" }),
70
70
  /* @__PURE__ */ o("span", { className: "icono-nombre-app", children: "Mi Perfil" })
71
71
  ]
72
72
  },
@@ -1,13 +1,14 @@
1
- import { jsx as p } from "react/jsx-runtime";
2
- import { useState as g, useEffect as S } from "react";
1
+ import { jsx as v } from "react/jsx-runtime";
2
+ import { useState as p, useEffect as S } from "react";
3
3
  import { useLocation as I, Outlet as _ } from "react-router-dom";
4
4
  import { j as u } from "../../index-CuHybtft.js";
5
5
  const W = () => {
6
- const [k, o] = g(!1), m = I(), s = `${window.location.protocol}//${window.location.host}/`, n = `${window.location.host}`, w = async () => {
6
+ const [k, o] = p(!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: {
10
- "Content-Type": "application/json"
10
+ "Content-Type": "application/json",
11
+ Authorization: `Bearer ${localStorage.getItem("access_token")}`
11
12
  },
12
13
  credentials: "include"
13
14
  })).ok)
@@ -17,8 +18,8 @@ const W = () => {
17
18
  return S(() => {
18
19
  const h = async () => {
19
20
  try {
20
- if (localStorage.getItem("auth_state")) {
21
- const c = localStorage.getItem("access_token");
21
+ if (localStorage.getItem("access_token")) {
22
+ const c = localStorage.getItem("auth_state");
22
23
  if (c) {
23
24
  const f = u(c).user.servicios.map((e) => e.url).filter((e) => !!e), r = m.pathname, a = f.map(
24
25
  (e) => e.startsWith("/") ? e : `/${e}`
@@ -33,7 +34,7 @@ const W = () => {
33
34
  } catch {
34
35
  try {
35
36
  if (await w()) {
36
- const l = localStorage.getItem("access_token");
37
+ const l = localStorage.getItem("auth_state");
37
38
  if (l) {
38
39
  const r = u(l).user.servicios.map((t) => t.url).filter((t) => !!t), a = m.pathname, i = r.map(
39
40
  (t) => t.startsWith("/") ? t : `/${t}`
@@ -51,7 +52,7 @@ const W = () => {
51
52
  }
52
53
  };
53
54
  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));
54
- }, []), k ? /* @__PURE__ */ p(_, {}) : null;
55
+ }, []), k ? /* @__PURE__ */ v(_, {}) : null;
55
56
  };
56
57
  export {
57
58
  W as ProtectedRoute
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.4",
5
+ "version": "1.8.0-pre.6",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": {