delete comment / reply working

This commit is contained in:
isUnknown 2024-10-30 16:32:13 +01:00
parent 58c08690f8
commit ac48b4166a
5 changed files with 131 additions and 59 deletions

View file

@ -144,6 +144,29 @@ export const useApiStore = defineStore("api", () => {
}
}
async function deleteComment(comment) {
const headers = {
method: "POST",
body: JSON.stringify(comment),
};
try {
const response = await fetch("/delete-comment.json", headers);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const newFile = await response.json();
return newFile;
} catch (error) {
console.error(
"Une erreur s'est produite lors de la suppression du commentaire :",
comment,
error
);
throw error;
}
}
async function replyComment(comment) {
const headers = {
method: "POST",
@ -198,6 +221,7 @@ export const useApiStore = defineStore("api", () => {
fetchData,
fetchRoute,
addComment,
deleteComment,
replyComment,
readNotification,
};