From 21259f2838630efbc5617886fe4929c30fc4f791 Mon Sep 17 00:00:00 2001 From: Giovanni-Josserand Date: Wed, 17 Dec 2025 17:22:10 +0100 Subject: [PATCH] update notification routes call --- src/components/Header/Header.jsx | 7 ++----- src/utils/notifications/deleteNotificationUser.js | 4 ++-- src/utils/notifications/getUserNotifications.js | 4 ++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/components/Header/Header.jsx b/src/components/Header/Header.jsx index 259bd7d..7c91356 100644 --- a/src/components/Header/Header.jsx +++ b/src/components/Header/Header.jsx @@ -2,7 +2,6 @@ import styles from "./Header.module.css" import { Link, NavLink } from "react-router"; import { useEffect, useRef, useState } from "react"; import getUserNotifications from "../../utils/notifications/getUserNotifications.js"; -import getUser from "../../utils/getUser.js"; import deleteNotificationUser from "../../utils/notifications/deleteNotificationUser.js"; function Header() { @@ -16,8 +15,7 @@ function Header() { useEffect(() => { async function loadNotifications() { - const user = await getUser(); - const notifData = await getUserNotifications(user.id); + const notifData = await getUserNotifications(); setNotifications(notifData || []); } @@ -44,8 +42,7 @@ function Header() { async function deleteNotification(notificationId) { try { - const user = await getUser(); - const result = await deleteNotificationUser(user.id, notificationId); + const result = await deleteNotificationUser(notificationId); console.log(result); diff --git a/src/utils/notifications/deleteNotificationUser.js b/src/utils/notifications/deleteNotificationUser.js index 0b8bef1..804c1dd 100644 --- a/src/utils/notifications/deleteNotificationUser.js +++ b/src/utils/notifications/deleteNotificationUser.js @@ -1,10 +1,10 @@ import getXSRFToken from "../getXSRF.js"; -export default async function deleteNotificationUser(userId, notificationId) { +export default async function deleteNotificationUser(notificationId) { const csrfToken = await getXSRFToken(); try { - const res = await fetch(`http://${import.meta.env.VITE_API_URL}/api/users/${userId}/delete/notification/${notificationId}`, { + const res = await fetch(`http://${import.meta.env.VITE_API_URL}/api/users/delete/notification/${notificationId}`, { method: 'DELETE', credentials: 'include', headers: { diff --git a/src/utils/notifications/getUserNotifications.js b/src/utils/notifications/getUserNotifications.js index 8f750ee..491471f 100644 --- a/src/utils/notifications/getUserNotifications.js +++ b/src/utils/notifications/getUserNotifications.js @@ -1,7 +1,7 @@ -export default async function getUserNotifications(id) { +export default async function getUserNotifications() { try { const response = await fetch( - `http://${import.meta.env.VITE_API_URL}/api/users/${id}/notifications`, + `http://${import.meta.env.VITE_API_URL}/api/users/notifications`, { method: 'GET', credentials: 'include',