react-ecosistema-unp 2.3.0 → 2.5.0-pre.0

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,70 +1,80 @@
1
- const n = () => `${window.location.protocol}//${window.location.host}/api-notificaciones`, e = () => {
2
- var a;
3
- const t = localStorage.getItem("auth_state"), o = t ? JSON.parse(t) : null;
4
- return ((a = o == null ? void 0 : o.user) == null ? void 0 : a.id_busuario) || "";
5
- }, r = async (t) => {
6
- const o = t.headers.get("content-type");
7
- return o && o.indexOf("application/json") !== -1 ? await t.json() : null;
8
- }, s = async () => {
1
+ import { getUserToken as c } from "../../../auth/services/User.js";
2
+ const t = () => `${window.location.protocol}//${window.location.host}/api-gateway`, r = () => ({
3
+ Authorization: `Bearer ${c()}`,
4
+ "BK-Service": "api-noti"
5
+ }), n = () => {
6
+ var e;
7
+ const a = localStorage.getItem("auth_state"), o = a ? JSON.parse(a) : null;
8
+ return ((e = o == null ? void 0 : o.user) == null ? void 0 : e.id_busuario) || "";
9
+ }, i = async (a) => {
10
+ const o = a.headers.get("content-type");
11
+ return o && o.indexOf("application/json") !== -1 ? await a.json() : null;
12
+ }, d = async () => {
9
13
  try {
10
- const t = await fetch(`${n()}/usuarios/${e()}/notificaciones/count-unread?medio=1`);
11
- if (!t.ok) return 0;
12
- const o = await r(t);
14
+ const a = await fetch(`${t()}/usuarios/${n()}/notificaciones/count-unread?medio=1`, {
15
+ headers: r()
16
+ });
17
+ if (!a.ok) return 0;
18
+ const o = await i(a);
13
19
  return o ? o.count : 0;
14
20
  } catch {
15
21
  return 0;
16
22
  }
17
- }, l = async (t, o = 1) => {
23
+ }, f = async (a, o = 1) => {
18
24
  try {
19
- let a = `${n()}/usuarios/${e()}/notificaciones?page=${o}&medio=1`;
20
- t !== void 0 && (a += `&leida=${t}`);
21
- const c = await fetch(a);
22
- return c.ok ? await r(c) || { count: 0, next: null, previous: null, results: [] } : { count: 0, next: null, previous: null, results: [] };
25
+ let e = `${t()}/usuarios/${n()}/notificaciones?page=${o}&medio=1`;
26
+ a !== void 0 && (e += `&leida=${a}`);
27
+ const s = await fetch(e, { headers: r() });
28
+ return s.ok ? await i(s) || { count: 0, next: null, previous: null, results: [] } : { count: 0, next: null, previous: null, results: [] };
23
29
  } catch {
24
30
  return { count: 0, next: null, previous: null, results: [] };
25
31
  }
26
- }, u = async (t) => {
32
+ }, h = async (a) => {
27
33
  try {
28
- const o = await fetch(`${n()}/usuarios/${e()}/notificaciones/${t}/marcar-leida/`, {
29
- method: "POST"
30
- }), a = await r(o);
31
- a && console.log(a.detail);
34
+ const o = await fetch(`${t()}/usuarios/${n()}/notificaciones/${a}/marcar-leida/`, {
35
+ method: "POST",
36
+ headers: r()
37
+ }), e = await i(o);
38
+ e && console.log(e.detail);
32
39
  } catch {
33
40
  console.error("Error al marcar como leída");
34
41
  }
35
- }, d = async (t) => {
42
+ }, m = async (a) => {
36
43
  try {
37
- const o = await fetch(`${n()}/usuarios/${e()}/notificaciones/${t}/marcar-no-leida/`, {
38
- method: "POST"
39
- }), a = await r(o);
40
- a && console.log(a.detail);
44
+ const o = await fetch(`${t()}/usuarios/${n()}/notificaciones/${a}/marcar-no-leida/`, {
45
+ method: "POST",
46
+ headers: r()
47
+ }), e = await i(o);
48
+ e && console.log(e.detail);
41
49
  } catch {
42
50
  console.error("Error al marcar como no leída");
43
51
  }
44
- }, f = async (t) => {
52
+ }, $ = async (a) => {
45
53
  try {
46
- const o = await fetch(`${n()}/usuarios/${e()}/notificaciones/${t}/eliminar/`, {
47
- method: "POST"
48
- }), a = await r(o);
49
- a && console.log(a.detail);
54
+ const o = await fetch(`${t()}/usuarios/${n()}/notificaciones/${a}/eliminar/`, {
55
+ method: "POST",
56
+ headers: r()
57
+ }), e = await i(o);
58
+ e && console.log(e.detail);
50
59
  } catch {
51
60
  console.error("Error al eliminar la notificación");
52
61
  }
53
- }, m = async () => {
62
+ }, w = async () => {
54
63
  try {
55
- const t = await fetch(`${n()}/usuarios/${e()}/notificaciones/eliminar-leidas/`, {
56
- method: "POST"
57
- }), o = await r(t);
64
+ const a = await fetch(`${t()}/usuarios/${n()}/notificaciones/eliminar-leidas/`, {
65
+ method: "POST",
66
+ headers: r()
67
+ }), o = await i(a);
58
68
  o && console.log(o.detail);
59
69
  } catch {
60
70
  console.error("Error al eliminar las notificaciones leídas");
61
71
  }
62
72
  };
63
73
  export {
64
- f as eliminarNotificacion,
65
- m as eliminarNotificacionesLeidas,
66
- l as getNotificaciones,
67
- s as getUnreadCount,
68
- u as marcarLeida,
69
- d as marcarNoLeida
74
+ $ as eliminarNotificacion,
75
+ w as eliminarNotificacionesLeidas,
76
+ f as getNotificaciones,
77
+ d as getUnreadCount,
78
+ h as marcarLeida,
79
+ m as marcarNoLeida
70
80
  };
@@ -8,7 +8,7 @@ const n = () => `${window.location.protocol}//${window.location.host}/api-gatewa
8
8
  const a = await o.json();
9
9
  return Array.isArray(a.documentos) ? a.documentos : [];
10
10
  }, i = async (e, t = "v1") => {
11
- t = "v1";
11
+ t = "v2";
12
12
  const r = `${n()}protecdoc/${t}/documentos/descargar/?id_documento=${encodeURIComponent(e)}`, o = await fetch(r, {
13
13
  headers: { Authorization: `Bearer ${c()}` }
14
14
  });
@@ -1,22 +1,24 @@
1
- async function c(r, o) {
1
+ import { getUserToken as c } from "../../auth/services/User.js";
2
+ async function s(t, o) {
2
3
  o(!0);
3
- const e = `${window.location.protocol}//${window.location.host}/api-gateway/hser/`, n = {
4
- identificacion: r,
5
- tipo: "nuip"
4
+ const e = `${window.location.protocol}//${window.location.host}/api-gateway/consulta-hser/`, a = {
5
+ cedula: t
6
6
  };
7
7
  try {
8
- const t = await fetch(e, {
8
+ const r = await fetch(e, {
9
9
  method: "POST",
10
10
  headers: {
11
- "Content-Type": "application/json"
11
+ "Content-Type": "application/json",
12
+ Authorization: `Bearer ${c()}`,
13
+ "BK-Service": "api-hei"
12
14
  },
13
- body: JSON.stringify(n)
14
- }), a = await t.json();
15
- return t.ok ? (o(!1), a) : (o(!1), []);
16
- } catch (t) {
17
- return console.error("Error fetching data:", t), o(!1), [];
15
+ body: JSON.stringify(a)
16
+ }), n = await r.json();
17
+ return r.ok ? (o(!1), n) : (o(!1), []);
18
+ } catch (r) {
19
+ return console.error("Error fetching data:", r), o(!1), [];
18
20
  }
19
21
  }
20
22
  export {
21
- c as fetchHistorico
23
+ s as fetchHistorico
22
24
  };
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": "2.3.0",
5
+ "version": "2.5.0-pre.0",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": {