show the error to the user when deleting a post

This commit is contained in:
Massedil
2025-06-18 18:14:28 +02:00
parent d4c28a113a
commit 1f8dc18feb
2 changed files with 21 additions and 4 deletions

View File

@@ -217,6 +217,7 @@ const {
} = useMutation<{
updatePost: IPost;
}>(UPDATE_POST);
const {
mutate: createPost,
onDone: onCreateDone,
@@ -402,8 +403,11 @@ const openDeletePostModal = async (): Promise<void> => {
});
};
const { mutate: deletePost, onDone: onDeletePostDone } =
useMutation(DELETE_POST);
const {
mutate: deletePost,
onDone: onDeletePostDone,
onError: onDeletePostError,
} = useMutation(DELETE_POST);
onDeletePostDone(({ data }) => {
if (data && post.value?.attributedTo) {
@@ -416,6 +420,11 @@ onDeletePostDone(({ data }) => {
}
});
onDeletePostError((error) => {
console.error(error);
alert(error.message);
});
useHead({
title: computed(() =>
props.isUpdate ? t("Edit post") : t("Add a new post")

View File

@@ -452,8 +452,11 @@ const openDeletePostModal = async (): Promise<void> => {
const router = useRouter();
const { mutate: deletePost, onDone: onDeletePostDone } =
useMutation(DELETE_POST);
const {
mutate: deletePost,
onDone: onDeletePostDone,
onError: onDeletePostError,
} = useMutation(DELETE_POST);
onDeletePostDone(({ data }) => {
if (data && post.value?.attributedTo) {
@@ -465,6 +468,11 @@ onDeletePostDone(({ data }) => {
});
}
});
onDeletePostError((error) => {
console.error(error);
alert(error.message);
});
</script>
<style lang="scss" scoped>
@use "@/styles/_mixins" as *;