update notification routes call
This commit is contained in:
1 parent
0aaafed26a
commit
21259f2838
3 files changed
+6
-9
No files matched your search
@@ -2,7 +2,6 @@ import styles from "./Header.module.css"
|
|||||||
import { Link, NavLink } from "react-router";
|
import { Link, NavLink } from "react-router";
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import getUserNotifications from "../../utils/notifications/getUserNotifications.js";
|
import getUserNotifications from "../../utils/notifications/getUserNotifications.js";
|
||||||
import getUser from "../../utils/getUser.js";
|
|
||||||
import deleteNotificationUser from "../../utils/notifications/deleteNotificationUser.js";
|
import deleteNotificationUser from "../../utils/notifications/deleteNotificationUser.js";
|
||||||
|
|
||||||
function Header() {
|
function Header() {
|
||||||
@@ -16,8 +15,7 @@ function Header() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function loadNotifications() {
|
async function loadNotifications() {
|
||||||
const user = await getUser();
|
const notifData = await getUserNotifications();
|
||||||
const notifData = await getUserNotifications(user.id);
|
|
||||||
setNotifications(notifData || []);
|
setNotifications(notifData || []);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,8 +42,7 @@ function Header() {
|
|||||||
|
|
||||||
async function deleteNotification(notificationId) {
|
async function deleteNotification(notificationId) {
|
||||||
try {
|
try {
|
||||||
const user = await getUser();
|
const result = await deleteNotificationUser(notificationId);
|
||||||
const result = await deleteNotificationUser(user.id, notificationId);
|
|
||||||
|
|
||||||
console.log(result);
|
console.log(result);
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import getXSRFToken from "../getXSRF.js";
|
import getXSRFToken from "../getXSRF.js";
|
||||||
|
|
||||||
export default async function deleteNotificationUser(userId, notificationId) {
|
export default async function deleteNotificationUser(notificationId) {
|
||||||
const csrfToken = await getXSRFToken();
|
const csrfToken = await getXSRFToken();
|
||||||
|
|
||||||
try {
|
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',
|
method: 'DELETE',
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
export default async function getUserNotifications(id) {
|
export default async function getUserNotifications() {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
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',
|
method: 'GET',
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
|
|||||||
Reference in new issue
Block a user