Notifications page : mark all as read working
This commit is contained in:
parent
cdf663d4ca
commit
5c9f450539
7 changed files with 76 additions and 19 deletions
|
|
@ -212,6 +212,24 @@ export const useApiStore = defineStore("api", () => {
|
|||
}
|
||||
}
|
||||
|
||||
async function readAllNotifications() {
|
||||
try {
|
||||
const response = await fetch("/read-all-notifications.json");
|
||||
if (!response.ok) {
|
||||
console.log(response);
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
const data = await response.json();
|
||||
if (data.error) {
|
||||
throw new Error(data);
|
||||
} else {
|
||||
console.log("All notifications read.");
|
||||
}
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
fetchDataThroughKQL,
|
||||
fetchData,
|
||||
|
|
@ -220,5 +238,6 @@ export const useApiStore = defineStore("api", () => {
|
|||
deleteComment,
|
||||
replyComment,
|
||||
readNotification,
|
||||
readAllNotifications,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,5 +18,11 @@ export const useUserStore = defineStore("user", () => {
|
|||
});
|
||||
}
|
||||
|
||||
return { user, notifications, readNotification };
|
||||
function readAllNotifications(notificationId) {
|
||||
user.value.notifications.forEach((notification) => {
|
||||
notification.isRead = true;
|
||||
});
|
||||
}
|
||||
|
||||
return { user, notifications, readNotification, readAllNotifications };
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue