react-ecosistema-unp 1.3.0-pre-release.6 → 1.3.0-pre-release.7

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,16 +1,16 @@
1
1
  import { jsx as m } from "react/jsx-runtime";
2
2
  import { useState as p, useEffect as h } from "react";
3
- import { useNavigate as k, useLocation as T, Outlet as v } from "react-router-dom";
4
- import { urlAuthDev as A, urlAuthTest as U, urlAuthProd as g, urlAuthLocal as j } from "../Url.js";
5
- import { j as y } from "../../index-CuHybtft.js";
6
- const D = ({ server: o }) => {
7
- const [l, s] = p(!1), t = k(), c = T();
8
- let e;
9
- return o === "dev" ? e = A : o === "test" ? e = U : o === "prod" ? e = g : e = j, h(() => {
3
+ import { useNavigate as w, useLocation as k, Outlet as T } from "react-router-dom";
4
+ import { urlAuthDev as v, urlAuthTest as A, urlAuthProd as U, urlAuthLocal as g } from "../Url.js";
5
+ import { j } from "../../index-CuHybtft.js";
6
+ const D = ({ server: e }) => {
7
+ const [l, s] = p(!1), t = w(), c = k();
8
+ let o;
9
+ return e === "dev" ? o = v : e === "test" ? o = A : e === "prod" ? o = U : o = g, h(() => {
10
10
  (async () => {
11
11
  try {
12
12
  if ((await fetch(
13
- `${e}/auth/validate/`,
13
+ `${o}/auth/validate/`,
14
14
  {
15
15
  method: "POST",
16
16
  headers: {
@@ -21,23 +21,20 @@ const D = ({ server: o }) => {
21
21
  )).ok) {
22
22
  const i = sessionStorage.getItem("user_token");
23
23
  if (i) {
24
- const u = y(i).datos_basicos.rutas, r = c.pathname, d = u.map(
25
- (a) => a.startsWith("/") ? a : `/${a}`
26
- ), f = r.startsWith("/") ? r : `/${r}`;
27
- if (d.includes(f))
28
- s(!0);
29
- else
30
- return s(!1), t("/");
24
+ const d = j(i).datos_basicos.rutas, a = c.pathname, u = d.map(
25
+ (n) => n.startsWith("/") ? n : `/${n}`
26
+ ), f = a.startsWith("/") ? a : `/${a}`;
27
+ u.includes(f) ? s(!0) : (s(!1), t("/"), window.location.reload());
31
28
  } else
32
- return s(!1), t("/");
29
+ s(!1), t("/"), window.location.reload();
33
30
  } else
34
- return t("/");
35
- } catch (n) {
36
- return console.error("Validation error:", n), t("/");
31
+ t("/"), window.location.reload();
32
+ } catch (r) {
33
+ console.error("Validation error:", r), t("/"), window.location.reload();
37
34
  } finally {
38
35
  }
39
36
  })();
40
- }, [t]), l ? /* @__PURE__ */ m(v, {}) : null;
37
+ }, [t]), l ? /* @__PURE__ */ m(T, {}) : null;
41
38
  };
42
39
  export {
43
40
  D 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.3.0-pre-release.6",
5
+ "version": "1.3.0-pre-release.7",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": {