update notification routes call
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user