show the error to the user when deleting a post
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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 *;
|
||||
|
||||
Reference in New Issue
Block a user