add of getUserNotifications function

This commit is contained in:
2025-11-16 12:13:30 +01:00
parent 4e40bba0b7
commit b5bb7b643b
2 changed files with 31 additions and 6 deletions
+10 -6
View File
@@ -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) => (
<div className={styles.notification} key={index}>
<p>{notification}</p>
<p>{notification.content}</p>
<button
className={styles.closeBtn}
onClick={() => setNotifications(prev => prev.filter((_, i) => i !== index))}