Skip to content

Commit 9f5a7f8

Browse files
committed
feat(web): display error when a notification mutation fails
1 parent ae14886 commit 9f5a7f8

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

web/components/Notifications/Item.vue

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,20 @@ const icon = computed<{ component: Component; color: string } | null>(() => {
3939
return null;
4040
});
4141
42-
const archive = useMutation(archiveMutation, {
43-
variables: { id: props.id },
44-
});
42+
const archive = reactive(
43+
useMutation(archiveMutation, {
44+
variables: { id: props.id },
45+
})
46+
);
47+
48+
const deleteNotification = reactive(
49+
useMutation(deleteMutation, {
50+
variables: { id: props.id, type: props.type },
51+
})
52+
);
4553
46-
const deleteNotification = useMutation(deleteMutation, {
47-
variables: { id: props.id, type: props.type },
54+
const mutationError = computed(() => {
55+
return archive.error?.message ?? deleteNotification.error?.message;
4856
});
4957
</script>
5058

@@ -81,6 +89,8 @@ const deleteNotification = useMutation(deleteMutation, {
8189
<p class="text-secondary-foreground">{{ description }}</p>
8290
</div>
8391

92+
<p v-if="mutationError" class="text-red-600">Error: {{ mutationError }}</p>
93+
8494
<div class="flex justify-end items-baseline gap-2">
8595
<a v-if="link" :href="link">
8696
<Button type="button" variant="outline" size="xs">

0 commit comments

Comments
 (0)