fix(schedules): actually persist the professional's opening hours
Saving opening hours from the app never did anything. The payload went to
PATCH /professionals/me as a map keyed by day name ({"monday": {"habilitado":
true, "range1Hour1": "8:0"}}), and that endpoint silently drops a `schedules`
key — it answers 200 with the record unchanged. So the professional edited
their hours, got "Información actualizada correctamente", and the agenda kept
whatever it had.
The real endpoint is PATCH /professionals/me/schedules and it takes an array
of {day_of_week, enabled, continuous_day, range*_hour*} with zero-padded
times, which is what the web has been sending all along.
Verified against the backend: the previous payload returns 200 and changes
nothing; the new one returns 200 and the rows come back updated.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
29ff91a790
commit
0bf96a935d
@@ -63,6 +63,24 @@ class Schedules extends Equatable {
|
||||
);
|
||||
}
|
||||
|
||||
/// The array PATCH /professionals/me/schedules expects, ordered
|
||||
/// 0 = Monday … 6 = Sunday.
|
||||
///
|
||||
/// The map form below is NOT accepted by the backend: sending it to
|
||||
/// /professionals/me returns 200 and silently discards the schedules, which
|
||||
/// is why editing opening hours appeared to work and never persisted.
|
||||
List<Map<String, dynamic>> toSchedulesArray() {
|
||||
return [
|
||||
monday.toScheduleDto(0),
|
||||
tuesday.toScheduleDto(1),
|
||||
wednesday.toScheduleDto(2),
|
||||
thursday.toScheduleDto(3),
|
||||
friday.toScheduleDto(4),
|
||||
saturday.toScheduleDto(5),
|
||||
sunday.toScheduleDto(6),
|
||||
];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'monday': monday.toJson(),
|
||||
|
||||
Reference in New Issue
Block a user