move utils files

This commit is contained in:
2025-12-17 14:16:08 +01:00
parent 883b9b6c4b
commit 0aaafed26a
13 changed files with 58 additions and 9 deletions
+25 -2
View File
@@ -1,8 +1,9 @@
import styles from "./Header.module.css"
import { Link, NavLink } from "react-router";
import { useEffect, useRef, useState } from "react";
import getUserNotifications from "../../utils/getUserNotifications.js";
import getUserNotifications from "../../utils/notifications/getUserNotifications.js";
import getUser from "../../utils/getUser.js";
import deleteNotificationUser from "../../utils/notifications/deleteNotificationUser.js";
function Header() {
const [notificationMenu, setnotificationMenu] = useState(false);
@@ -37,6 +38,28 @@ function Header() {
};
}, []);
async function deleteNotification(notificationId) {
try {
const user = await getUser();
const result = await deleteNotificationUser(user.id, notificationId);
console.log(result);
if (result) {
setNotifications(prev => prev.filter(n => n.id !== notificationId));
}
} catch (err) {
console.error('Erreur suppression notification :', err);
}
}
return (
<div className={styles.headerContainer}>
<header className={`${styles.header} glassCard`}>
@@ -114,7 +137,7 @@ function Header() {
<p>{notification.content}</p>
<button
className={styles.closeBtn}
onClick={() => setNotifications(prev => prev.filter((_, i) => i !== index))}
onClick={() => deleteNotification(notification.id)}
>
<img src="close.svg" alt="supprimer la notification"/>
</button>