Update SettingsPage to replace notifications with language preference

Replaced the deprecated notifications option with a language selector in `SettingsPage`. Updated localStorage parsing to strip deprecated fields and added UI support for the new language preference.
This commit is contained in:
2025-11-22 22:16:24 -04:00
parent 86d5ffea86
commit 48505fe3b5

View File

@@ -5,7 +5,7 @@ import '../../styles/components.css';
const DEFAULT_SETTINGS = { const DEFAULT_SETTINGS = {
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC', timezone: Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC',
theme: 'light', theme: 'light',
notifications: true, language: 'es',
apiBaseUrl: '' apiBaseUrl: ''
}; };
@@ -14,7 +14,9 @@ const loadSettings = () => {
const raw = localStorage.getItem('app_settings'); const raw = localStorage.getItem('app_settings');
if (!raw) return DEFAULT_SETTINGS; if (!raw) return DEFAULT_SETTINGS;
const parsed = JSON.parse(raw); const parsed = JSON.parse(raw);
return { ...DEFAULT_SETTINGS, ...parsed }; // Strip deprecated fields like 'notifications' if present in older storage
const { notifications, ...rest } = parsed || {};
return { ...DEFAULT_SETTINGS, ...rest };
} catch { } catch {
return DEFAULT_SETTINGS; return DEFAULT_SETTINGS;
} }
@@ -99,15 +101,11 @@ const SettingsPage = () => {
</div> </div>
<div className="form-group"> <div className="form-group">
<label className="checkbox"> <label htmlFor="language">Idioma</label>
<input <select id="language" name="language" value={settings.language} onChange={handleChange}>
type="checkbox" <option value="es">Español</option>
name="notifications" <option value="en">English</option>
checked={settings.notifications} </select>
onChange={handleChange}
/>
Habilitar notificaciones
</label>
</div> </div>
<div className="form-group" style={{ gridColumn: '1 / -1' }}> <div className="form-group" style={{ gridColumn: '1 / -1' }}>