read comment working
This commit is contained in:
parent
583daa1759
commit
39fc379541
12 changed files with 125 additions and 78 deletions
|
|
@ -189,28 +189,25 @@ export const useApiStore = defineStore("api", () => {
|
|||
}
|
||||
}
|
||||
|
||||
async function readNotification(userUuid, group, notificationId) {
|
||||
async function readNotification(notificationId) {
|
||||
const headers = {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
userUuid,
|
||||
notificationId,
|
||||
group,
|
||||
}),
|
||||
};
|
||||
try {
|
||||
const response = await fetch("/mark-as-read.json", headers);
|
||||
const response = await fetch("/read-comment.json", headers);
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
const newNotifications = await response.json();
|
||||
return newNotifications;
|
||||
const data = await response.json();
|
||||
if (data.error) {
|
||||
throw new Error(data);
|
||||
} else {
|
||||
return data;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(
|
||||
"Une erreur s'est produite lors de la lecture de la notification n°",
|
||||
notificationId,
|
||||
error
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,5 +10,13 @@ export const useUserStore = defineStore("user", () => {
|
|||
: Object.values(user.value.notifications);
|
||||
});
|
||||
|
||||
return { user, notifications };
|
||||
function readNotification(notificationId) {
|
||||
user.value.notifications.forEach((notification) => {
|
||||
if (notification.id === notificationId) {
|
||||
notification.isRead = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return { user, notifications, readNotification };
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue