From 2dbfb79e7213047b0bb8bb73dfb4ce4063bda662 Mon Sep 17 00:00:00 2001 From: Andrei Date: Thu, 9 Oct 2025 13:12:10 +0000 Subject: [PATCH] fix: Enable push notifications toggle in settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed two critical issues in user settings: 1. Settings save 400 error - Removed invalid notifications boolean that didn't match backend DTO structure 2. Push notifications toggle not working - Properly structured notifications preferences as nested object with pushEnabled/emailEnabled Changes: - Updated state to use pushEnabled instead of simple notifications boolean - Load pushEnabled from user.preferences.notifications.pushEnabled - Send notifications as nested object to match UpdateProfileDto - Both push and email notification toggles now work independently Backend DTO expects: { preferences: { notifications: { pushEnabled: boolean, emailEnabled: boolean } } } 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- maternal-web/app/settings/page.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/maternal-web/app/settings/page.tsx b/maternal-web/app/settings/page.tsx index 7d7afd2..55628a6 100644 --- a/maternal-web/app/settings/page.tsx +++ b/maternal-web/app/settings/page.tsx @@ -31,7 +31,7 @@ export default function SettingsPage() { const [timezone, setTimezone] = useState(user?.timezone || 'UTC'); const [timeFormat, setTimeFormat] = useState<'12h' | '24h'>(user?.preferences?.timeFormat || '12h'); const [settings, setSettings] = useState({ - notifications: true, + pushEnabled: true, emailUpdates: false, darkMode: false, measurementUnit: 'metric' as 'metric' | 'imperial', @@ -45,7 +45,7 @@ export default function SettingsPage() { useEffect(() => { if (user?.preferences) { setSettings({ - notifications: user.preferences.notifications ?? true, + pushEnabled: user.preferences.notifications?.pushEnabled ?? true, emailUpdates: user.preferences.emailUpdates ?? false, darkMode: user.preferences.darkMode ?? false, measurementUnit: (user.preferences.measurementUnit as 'metric' | 'imperial') || 'metric', @@ -84,7 +84,13 @@ export default function SettingsPage() { photoUrl: photoUrl || undefined, timezone, preferences: { - ...settings, + notifications: { + pushEnabled: settings.pushEnabled, + emailEnabled: settings.emailUpdates, + }, + emailUpdates: settings.emailUpdates, + darkMode: settings.darkMode, + measurementUnit: settings.measurementUnit, timeFormat, } }); @@ -235,8 +241,8 @@ export default function SettingsPage() { setSettings({ ...settings, notifications: e.target.checked })} + checked={settings.pushEnabled} + onChange={(e) => setSettings({ ...settings, pushEnabled: e.target.checked })} disabled={isLoading} /> }