From b5bb7b643b53f70fc25a42a5198a1a1689518efe Mon Sep 17 00:00:00 2001 From: Giovanni-Josserand Date: Sun, 16 Nov 2025 12:13:30 +0100 Subject: [PATCH] add of getUserNotifications function --- src/components/Header/Header.jsx | 16 ++++++++++------ src/utils/getUserNotifications.js | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 src/utils/getUserNotifications.js diff --git a/src/components/Header/Header.jsx b/src/components/Header/Header.jsx index c04a7ab..ea9ad80 100644 --- a/src/components/Header/Header.jsx +++ b/src/components/Header/Header.jsx @@ -1,20 +1,24 @@ import styles from "./Header.module.css" import { Link, NavLink } from "react-router"; import { useEffect, useRef, useState } from "react"; +import getUserNotifications from "../../utils/getUserNotifications.js"; function Header() { const [notificationMenu, setnotificationMenu] = useState(false); const [unreadNotification, setunreadNotification] = useState(true); const [mobileMenu, setMobileMenu] = useState(false); + const [notifications, setNotifications] = useState([]); const notificationRef = useRef(null); - const [notifications, setNotifications] = useState([ - "Vous avez un nouveau message !", - "Jean Paul est en attente de validation !", - "Vous avez un nouveau message !" - ]); + useEffect(() => { + async function loadNotifications() { + const notifData = await getUserNotifications(); + setNotifications(notifData || []); + } + + loadNotifications(); const handleClickOutside = (event) => { if ( notificationRef.current && @@ -109,7 +113,7 @@ function Header() { ) : ( notifications.map((notification, index) => (
-

{notification}

+

{notification.content}