fix: Enable push notifications toggle in settings
Some checks failed
ParentFlow CI/CD Pipeline / Backend Tests (push) Has been cancelled
ParentFlow CI/CD Pipeline / Frontend Tests (push) Has been cancelled
ParentFlow CI/CD Pipeline / Security Scanning (push) Has been cancelled
ParentFlow CI/CD Pipeline / Build Docker Images (map[context:maternal-app/maternal-app-backend dockerfile:Dockerfile.production name:backend]) (push) Has been cancelled
ParentFlow CI/CD Pipeline / Build Docker Images (map[context:maternal-web dockerfile:Dockerfile.production name:frontend]) (push) Has been cancelled
ParentFlow CI/CD Pipeline / Deploy to Development (push) Has been cancelled
ParentFlow CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Lint and Test (push) Has been cancelled
CI/CD Pipeline / E2E Tests (push) Has been cancelled
CI/CD Pipeline / Build Application (push) Has been cancelled

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 <noreply@anthropic.com>
This commit is contained in:
Andrei
2025-10-09 13:12:10 +00:00
parent 2be0e90f19
commit 2dbfb79e72

View File

@@ -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() {
<FormControlLabel
control={
<Switch
checked={settings.notifications}
onChange={(e) => setSettings({ ...settings, notifications: e.target.checked })}
checked={settings.pushEnabled}
onChange={(e) => setSettings({ ...settings, pushEnabled: e.target.checked })}
disabled={isLoading}
/>
}