fix: include adaptive_mode when enabling adaptive timing toggle
The API requires adaptive_mode when adaptive_timing_enabled is true, but the frontend was only sending the enabled flag. This caused 400 errors when users tried to toggle adaptive timing on. Now the toggle sends both fields when enabling, satisfying the API validation requirements.
This commit is contained in:
@@ -427,7 +427,14 @@ export default function SettingsPage() {
|
||||
<p className="text-sm text-gray-500 dark:text-gray-400">Adjust medication times based on your wake time</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => updateAdaptiveMeds({ adaptive_timing_enabled: !adaptiveMeds.adaptive_timing_enabled })}
|
||||
onClick={() => {
|
||||
const newEnabled = !adaptiveMeds.adaptive_timing_enabled;
|
||||
const updates: Partial<AdaptiveMedSettings> = { adaptive_timing_enabled: newEnabled };
|
||||
if (newEnabled) {
|
||||
updates.adaptive_mode = adaptiveMeds.adaptive_mode;
|
||||
}
|
||||
updateAdaptiveMeds(updates);
|
||||
}}
|
||||
className={`w-12 h-7 rounded-full transition-colors ${
|
||||
adaptiveMeds.adaptive_timing_enabled ? 'bg-indigo-500' : 'bg-gray-300 dark:bg-gray-600'
|
||||
}`}
|
||||
|
||||
Reference in New Issue
Block a user