Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

feat: add error handling for dashboard layout updates with toast notifications

daniel31x1398c1a1f03595
diff --git a/apps/web/components/DashboardLayoutDropdown.tsx b/apps/web/components/DashboardLayoutDropdown.tsx
index 6dcb61ec..8a77fabd 100644
--- a/apps/web/components/DashboardLayoutDropdown.tsx
+++ b/apps/web/components/DashboardLayoutDropdown.tsx
@@ -30,6 +30,7 @@ import {
} from "@dnd-kit/core";
import { restrictToParentElement } from "@dnd-kit/modifiers";
import { cn } from "@linkwarden/lib";
+import toast from "react-hot-toast";
interface DashboardSectionOption {
type: DashboardSectionType;
@@ -185,7 +186,13 @@ export default function DashboardLayoutDropdown() {
return s;
});
- updateDashboardLayout.mutateAsync(updatedSections);
+ updateDashboardLayout.mutateAsync(updatedSections, {
+ onSettled: (data, error) => {
+ if (error) {
+ toast.error(error.message);
+ }
+ },
+ });
};
const handleReorder = (sourceId: string, destId: string) => {
@@ -217,7 +224,13 @@ export default function DashboardLayoutDropdown() {
const disabledSections = filteredSections.filter((s) => !s.enabled);
const updated = [...reorderedWithNewOrders, ...disabledSections];
- updateDashboardLayout.mutateAsync(updated);
+ updateDashboardLayout.mutateAsync(updated, {
+ onSettled: (data, error) => {
+ if (error) {
+ toast.error(error.message);
+ }
+ },
+ });
};
const handleDragEnd = (event: DragEndEvent) => {