From 56b99dfcef653aa6ea709fc5e1f16d9f1515c69c Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Mon, 16 Feb 2026 20:34:35 +0100 Subject: [PATCH] fix: improve error handling in notifications and organization settings for better user feedback --- app/notifications/page.tsx | 4 ++-- components/settings/OrganizationSettings.tsx | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/notifications/page.tsx b/app/notifications/page.tsx index 679d1b8..c3f1b94 100644 --- a/app/notifications/page.tsx +++ b/app/notifications/page.tsx @@ -99,8 +99,8 @@ export default function NotificationsPage() { setNotifications((prev) => prev.map((n) => ({ ...n, read: true }))) setUnreadCount(0) toast.success('All notifications marked as read') - } catch { - toast.error(getAuthErrorMessage(new Error('Failed to mark all as read'))) + } catch (err) { + toast.error(getAuthErrorMessage(err as Error) || 'Failed to mark all as read') } } diff --git a/components/settings/OrganizationSettings.tsx b/components/settings/OrganizationSettings.tsx index 3e72400..7cd052f 100644 --- a/components/settings/OrganizationSettings.tsx +++ b/components/settings/OrganizationSettings.tsx @@ -1012,6 +1012,7 @@ export default function OrganizationSettings() { aria-checked={notificationSettings[cat.id] !== false} aria-label={`${notificationSettings[cat.id] !== false ? 'Disable' : 'Enable'} ${cat.label} notifications`} onClick={() => { + const prev = { ...notificationSettings } const next = { ...notificationSettings, [cat.id]: notificationSettings[cat.id] === false } setNotificationSettings(next) setIsSavingNotificationSettings(true) @@ -1021,7 +1022,7 @@ export default function OrganizationSettings() { }) .catch((err) => { toast.error(getAuthErrorMessage(err) || 'Failed to update settings') - setNotificationSettings(notificationSettings) + setNotificationSettings(prev) }) .finally(() => setIsSavingNotificationSettings(false)) }}