show the error to the user when deleting a post
This commit is contained in:
@@ -217,6 +217,7 @@ const {
|
|||||||
} = useMutation<{
|
} = useMutation<{
|
||||||
updatePost: IPost;
|
updatePost: IPost;
|
||||||
}>(UPDATE_POST);
|
}>(UPDATE_POST);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
mutate: createPost,
|
mutate: createPost,
|
||||||
onDone: onCreateDone,
|
onDone: onCreateDone,
|
||||||
@@ -402,8 +403,11 @@ const openDeletePostModal = async (): Promise<void> => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const { mutate: deletePost, onDone: onDeletePostDone } =
|
const {
|
||||||
useMutation(DELETE_POST);
|
mutate: deletePost,
|
||||||
|
onDone: onDeletePostDone,
|
||||||
|
onError: onDeletePostError,
|
||||||
|
} = useMutation(DELETE_POST);
|
||||||
|
|
||||||
onDeletePostDone(({ data }) => {
|
onDeletePostDone(({ data }) => {
|
||||||
if (data && post.value?.attributedTo) {
|
if (data && post.value?.attributedTo) {
|
||||||
@@ -416,6 +420,11 @@ onDeletePostDone(({ data }) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onDeletePostError((error) => {
|
||||||
|
console.error(error);
|
||||||
|
alert(error.message);
|
||||||
|
});
|
||||||
|
|
||||||
useHead({
|
useHead({
|
||||||
title: computed(() =>
|
title: computed(() =>
|
||||||
props.isUpdate ? t("Edit post") : t("Add a new post")
|
props.isUpdate ? t("Edit post") : t("Add a new post")
|
||||||
|
|||||||
@@ -452,8 +452,11 @@ const openDeletePostModal = async (): Promise<void> => {
|
|||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const { mutate: deletePost, onDone: onDeletePostDone } =
|
const {
|
||||||
useMutation(DELETE_POST);
|
mutate: deletePost,
|
||||||
|
onDone: onDeletePostDone,
|
||||||
|
onError: onDeletePostError,
|
||||||
|
} = useMutation(DELETE_POST);
|
||||||
|
|
||||||
onDeletePostDone(({ data }) => {
|
onDeletePostDone(({ data }) => {
|
||||||
if (data && post.value?.attributedTo) {
|
if (data && post.value?.attributedTo) {
|
||||||
@@ -465,6 +468,11 @@ onDeletePostDone(({ data }) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onDeletePostError((error) => {
|
||||||
|
console.error(error);
|
||||||
|
alert(error.message);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@use "@/styles/_mixins" as *;
|
@use "@/styles/_mixins" as *;
|
||||||
|
|||||||
Reference in New Issue
Block a user