fix: improve error handling in notifications and organization settings for better user feedback

This commit is contained in:
Usman Baig
2026-02-16 20:34:35 +01:00
parent 4a48945486
commit 56b99dfcef
2 changed files with 4 additions and 3 deletions

View File

@@ -99,8 +99,8 @@ export default function NotificationsPage() {
setNotifications((prev) => prev.map((n) => ({ ...n, read: true }))) setNotifications((prev) => prev.map((n) => ({ ...n, read: true })))
setUnreadCount(0) setUnreadCount(0)
toast.success('All notifications marked as read') toast.success('All notifications marked as read')
} catch { } catch (err) {
toast.error(getAuthErrorMessage(new Error('Failed to mark all as read'))) toast.error(getAuthErrorMessage(err as Error) || 'Failed to mark all as read')
} }
} }

View File

@@ -1012,6 +1012,7 @@ export default function OrganizationSettings() {
aria-checked={notificationSettings[cat.id] !== false} aria-checked={notificationSettings[cat.id] !== false}
aria-label={`${notificationSettings[cat.id] !== false ? 'Disable' : 'Enable'} ${cat.label} notifications`} aria-label={`${notificationSettings[cat.id] !== false ? 'Disable' : 'Enable'} ${cat.label} notifications`}
onClick={() => { onClick={() => {
const prev = { ...notificationSettings }
const next = { ...notificationSettings, [cat.id]: notificationSettings[cat.id] === false } const next = { ...notificationSettings, [cat.id]: notificationSettings[cat.id] === false }
setNotificationSettings(next) setNotificationSettings(next)
setIsSavingNotificationSettings(true) setIsSavingNotificationSettings(true)
@@ -1021,7 +1022,7 @@ export default function OrganizationSettings() {
}) })
.catch((err) => { .catch((err) => {
toast.error(getAuthErrorMessage(err) || 'Failed to update settings') toast.error(getAuthErrorMessage(err) || 'Failed to update settings')
setNotificationSettings(notificationSettings) setNotificationSettings(prev)
}) })
.finally(() => setIsSavingNotificationSettings(false)) .finally(() => setIsSavingNotificationSettings(false))
}} }}