fix(mood): surface a toast when a list delete fails

The mood list delete mutation had no onError handler, so a rejected
DELETE cleared no state and showed nothing — the row stayed in place
with no signal the request was refused. Add an error toast on failure,
mirroring the medication-card silent-failure fix.
This commit is contained in:
Marc-André Bombeck committed 2026-06-04 18:37:23 +02:00
1 parent 31301cc889
commit ccf56b8dbb
1 file changed
+8
+8
View File
@@ -63,6 +63,7 @@ import {
} from "lucide-react";
import { useId, useState } from "react";
import { createPortal } from "react-dom";
import { toast } from "sonner";
import { formatDateTime } from "@/lib/format";
import { useTranslations, useFormatters } from "@/lib/i18n/context";
import {
@@ -206,6 +207,13 @@ export function MoodList({ onAddFirst }: MoodListProps = {}) {
onSuccess: () => {
void invalidateKeys(queryClient, moodDependentKeys);
},
// v1.11.5 — a failed delete used to fail silently (no onError handler),
// leaving the row in place with no signal that the request was rejected.
// Surface the failure so the user knows to retry. Mirrors the v1.11.3
// medication-card silent-failure fix.
onError: () => {
toast.error(t("mood.deleteError"));
},
});
const updateMutation = useMutation({