Ver código fonte

Avance notificación pg

ElPoteito 6 meses atrás
pai
commit
282acc0de5
1 arquivos alterados com 20 adições e 11 exclusões
  1. 20 11
      src/views/administracion/eventos/EventoDetalleGrupo.js

+ 20 - 11
src/views/administracion/eventos/EventoDetalleGrupo.js

@@ -336,13 +336,14 @@ const EventoDetalleGrupo = () => {
     try {
       setGuardando({ ...guardando, nuevo: true });
       const _usuarios = grupoEvento?.usuarios;
-      const _redesEvento = grupoEvento?.redes;
+      // const _redesEvento = grupoEvento?.redes;
+      const _redesEvento = models[0]?.urls;
       const plantilla = "nuevo_evento";
 
-      if (_usuarios?.length < 1) {
+      /* if (_usuarios?.length < 1) {
         message.info("Este evento no ha sido procesado aún.");
         return;
-      }
+      } */
 
       const arrUsuarios = [];
 
@@ -355,6 +356,9 @@ const EventoDetalleGrupo = () => {
       const eventoTw = _redesEvento.find((i) => i?.redSocial === "Twitter")
         ? true
         : false;
+      const eventoTt = _redesEvento.find((i) => i?.redSocial === "TikTok")
+        ? true
+        : false;
 
       _usuarios?.forEach((u) => {
         const uid = u?.uid;
@@ -373,22 +377,24 @@ const EventoDetalleGrupo = () => {
           fb: eventoFb && tieneFb,
           ig: eventoIg && tieneIg,
           tw: eventoTw && tieneTw,
+          tt: eventoTt /* && tieneTw */,
         };
 
         arrUsuarios.push(usuario);
       });
 
       const body = {
-        // idEvento: id,
+        id: models[0].id,
         plantilla: plantilla,
-        titulo: grupoEvento?.nombre,
+        titulo: models?.[0]?.nombre,
         estatus: "Nuevo",
         enviado: null,
         fecha: new Date(),
-        urlFB: `${REACT_APP_WEB_URL}evento-laud?id=${eventos?.find((e) => e.redSocial === "Facebook")?.id}`,
-        urlIG: `${REACT_APP_WEB_URL}evento-laud?id=${eventos?.find((e) => e.redSocial === "Instagram")?.id}`,
-        urlTW: `${REACT_APP_WEB_URL}evento-laud?id=${eventos?.find((e) => e.redSocial === "Twitter")?.id}`,
-        usuarios: arrUsuarios,
+        url: _redesEvento.map((e) => `${REACT_APP_WEB_URL}evento-laud?id=${models[0]?.id}&k=${e?.key}`),
+        // urlFB: `${REACT_APP_WEB_URL}evento-laud?id=${eventos?.find((e) => e.redSocial === "Facebook")?.id}`,
+        // urlIG: `${REACT_APP_WEB_URL}evento-laud?id=${eventos?.find((e) => e.redSocial === "Instagram")?.id}`,
+        // urlTW: `${REACT_APP_WEB_URL}evento-laud?id=${eventos?.find((e) => e.redSocial === "Twitter")?.id}`,
+        // usuarios: arrUsuarios,
       };
 
       if (!eventoFb) {
@@ -420,8 +426,11 @@ const EventoDetalleGrupo = () => {
         return;
       } */
 
-      await addDoc(collection(firestore, "notificaciones"), body);
-      message.success("Recordatorio enviado.");
+      // await addDoc(collection(firestore, "notificaciones"), body);
+      const res = await HttpService.post('v1/evento/notificar', body);
+      if (res?.status === 200) {
+        message.success("Recordatorio enviado.");
+      }
     } catch (error) {
       message.error("Error al enviar la notificacion");
       console.log("error al notificar: ", error);