react-ecosistema-unp 1.9.1-pre.2 → 1.9.1
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,28 +1,28 @@
|
|
|
1
|
-
import { FinSesionService as
|
|
2
|
-
import { y as
|
|
3
|
-
import { useState as
|
|
4
|
-
const
|
|
5
|
-
const [
|
|
6
|
-
return
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
9
|
-
const
|
|
10
|
-
|
|
1
|
+
import { FinSesionService as a } from "../services/FinSesionService.js";
|
|
2
|
+
import { y as e } from "../../index-Cs6Q8pv4.js";
|
|
3
|
+
import { useState as c, useEffect as l } from "react";
|
|
4
|
+
const w = () => {
|
|
5
|
+
const [t, i] = c(null), n = `${window.location.protocol}//${window.location.host}/`;
|
|
6
|
+
return l(() => {
|
|
7
|
+
const o = localStorage.getItem("auth_state");
|
|
8
|
+
if (o) {
|
|
9
|
+
const s = JSON.parse(o);
|
|
10
|
+
i(s);
|
|
11
11
|
}
|
|
12
12
|
}, []), { FinSesion: () => {
|
|
13
|
-
|
|
13
|
+
e.info("Finalizando sesión..."), new Promise(async (o, s) => {
|
|
14
14
|
try {
|
|
15
|
-
|
|
16
|
-
} catch (
|
|
17
|
-
|
|
15
|
+
await a((t == null ? void 0 : t.user.username) || "", n), e.dismiss(), e.success("Sesión finalizada con éxito"), o(!0);
|
|
16
|
+
} catch (r) {
|
|
17
|
+
e.dismiss(), e.warning("Sesión finalizada"), s(r);
|
|
18
18
|
} finally {
|
|
19
|
-
|
|
20
|
-
window.location.href =
|
|
19
|
+
sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), localStorage.removeItem("refresh_token"), setTimeout(() => {
|
|
20
|
+
window.location.href = n;
|
|
21
21
|
}, 1e3);
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
} };
|
|
25
25
|
};
|
|
26
26
|
export {
|
|
27
|
-
|
|
27
|
+
w as useFinalizarSesion
|
|
28
28
|
};
|