fix: surface remaining silent mutation failures

Four more mutations had no error feedback: equipment condition change,
task completion, and notification mark-as-read all failed silently.
More importantly, the offline sync badge computed a result.failed
count from syncPendingInspections() but never displayed it - an entry
rejected by the server (e.g. a validation rule) would sit in the
offline queue indefinitely with zero indication to the beekeeper why
it never syncs. Both the failed-count and outright sync-mutation
rejection now surface a toast.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
Nick SzaunigandClaude Sonnet 5 committed 2026-09-09 11:41:36 +02:00
1 parent 997dadfaaa
commit dfb4de81f8
4 files changed
+13

No files matched your search

@@ -3,6 +3,7 @@
import Link from "next/link";
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import { Bell } from "lucide-react";
import { toast } from "sonner";
import { fetchNotifications, markNotificationRead } from "@/lib/notifications/api";
import { Notification, NotificationPriority } from "@/lib/notifications/types";
import { Badge, badgeVariants } from "@/components/ui/badge";
@@ -41,6 +42,7 @@ export function NotificationBell() {
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: ["notifications"] });
},
onError: () => toast.error("Benachrichtigung konnte nicht als gelesen markiert werden"),
});
const unreadCount = notifications?.filter((notification) => !notification.read).length ?? 0;
@@ -26,7 +26,14 @@ export function OfflineSyncBadge() {
if (result.synced > 0) {
toast.success(`${result.synced} Eintrag/Einträge synchronisiert`);
}
if (result.failed > 0) {
toast.error(
`${result.failed} Eintrag/Einträge konnten nicht synchronisiert werden und bleiben in der Warteschlange`,
);
}
},
onError: () =>
toast.error("Synchronisierung fehlgeschlagen - wird beim nächsten Versuch erneut versucht"),
});
useEffect(() => {