From cebd7dfa1e5556b3d2dcd66a25dadadea9a86161 Mon Sep 17 00:00:00 2001 From: FRANCISCO Date: Wed, 6 Nov 2024 21:04:05 -0300 Subject: [PATCH] campana funcional para masivas [muestra todas] --- src/components/Campana.jsx | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/components/Campana.jsx b/src/components/Campana.jsx index 4cb388f..ef9c1e1 100644 --- a/src/components/Campana.jsx +++ b/src/components/Campana.jsx @@ -1,13 +1,23 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import '../pages/users/campana.css'; const Campana = () => { const [isOpen, setIsOpen] = useState(false); + const [notificaciones, setNotificaciones] = useState([]); const toggleNotifications = () => { setIsOpen(!isOpen); }; + useEffect(() => { + if (isOpen && notificaciones.length === 0) { + fetch('http://localhost:8000/onesignal/notificaciones/') + .then((response) => response.json()) + .then((data) => setNotificaciones(data)) + .catch((error) => console.error('Error fetching notifications:', error)); + } + }, [isOpen]); + return (
@@ -35,9 +45,16 @@ const Campana = () => {

Notificaciones

    -
  • Notificación 1
  • -
  • Notificación 2
  • -
  • Notificación 3
  • + {notificaciones.length > 0 ? ( + notificaciones.map((notificacion, index) => ( +
  • +
    {notificacion.title}
    +

    {notificacion.message}

    +
  • + )) + ) : ( +
  • No hay notificaciones disponibles
  • + )}
)}