import getXSRFToken from "../getXSRF.js";

export default async function deleteNotificationUser(notificationId) {
    const csrfToken = await getXSRFToken();

    try {
        const res = await fetch(`${import.meta.env.VITE_API_URL}/api/users/delete/notification/${notificationId}`, {
            method: 'DELETE',
            credentials: 'include',
            headers: {
                'Accept': 'application/json',
                'X-XSRF-TOKEN': csrfToken
            }
        });

        if (!res.ok) {
            throw new Error(`Erreur serveur : ${res.status}`);
        }

        const data = await res.json();
        return data;
    } catch (err) {
        console.error('Erreur :', err);
        return null;
    }
}
