move utils files
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user