Critical fixes for the scheduling flow:
- ScheduleEntity: add toScheduleDto() with snake_case keys, day_of_week,
and HH:MM zero-padded format required by the backend DTO @Matches validator
- Schedules: add toSchedulesArray() converting the day-keyed object to the
array format expected by PATCH /professionals/me/schedules
- ProfessionalFormProvider: updateProfesionalProfileScheduleInfo now calls
the correct endpoint (/professionals/me/schedules) instead of /professionals/me
which was stripping the schedules field via ValidationPipe whitelist
- Service.formatTimeOfDay: zero-pad hours and minutes so POST /services passes
the @Matches(/^\d{2}:\d{2}$/) DTO validation
- ProfessionalProvider: add getProfessionalById() calling /professionals/:id
(public endpoint) to load any professional's data, not the viewer's own
- CalendarServicesProvider: add getPublicServicesForProfessional() calling
/services/public-calendar/:id so the user calendar shows the target
professional's booked slots, not the viewer's own services
- CalendarView: use getProfessionalById + getPublicServicesForProfessional
so the calendar correctly reflects the selected professional's schedule
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
91 lines
2.6 KiB
Dart
91 lines
2.6 KiB
Dart
import 'package:prosapp_web_app/models/schedules_entity.dart';
|
|
|
|
class Schedules {
|
|
final ScheduleEntity monday;
|
|
final ScheduleEntity tuesday;
|
|
final ScheduleEntity wednesday;
|
|
final ScheduleEntity thursday;
|
|
final ScheduleEntity friday;
|
|
final ScheduleEntity saturday;
|
|
final ScheduleEntity sunday;
|
|
|
|
const Schedules({
|
|
required this.monday,
|
|
required this.tuesday,
|
|
required this.wednesday,
|
|
required this.thursday,
|
|
required this.friday,
|
|
required this.saturday,
|
|
required this.sunday,
|
|
});
|
|
|
|
static const empty = Schedules(
|
|
monday: ScheduleEntity.empty,
|
|
tuesday: ScheduleEntity.empty,
|
|
wednesday: ScheduleEntity.empty,
|
|
thursday: ScheduleEntity.empty,
|
|
friday: ScheduleEntity.empty,
|
|
saturday: ScheduleEntity.empty,
|
|
sunday: ScheduleEntity.empty,
|
|
);
|
|
|
|
// Copy function
|
|
Schedules copyWith({
|
|
ScheduleEntity? monday,
|
|
ScheduleEntity? tuesday,
|
|
ScheduleEntity? wednesday,
|
|
ScheduleEntity? thursday,
|
|
ScheduleEntity? friday,
|
|
ScheduleEntity? saturday,
|
|
ScheduleEntity? sunday,
|
|
}) {
|
|
return Schedules(
|
|
monday: monday ?? this.monday,
|
|
tuesday: tuesday ?? this.tuesday,
|
|
wednesday: wednesday ?? this.wednesday,
|
|
thursday: thursday ?? this.thursday,
|
|
friday: friday ?? this.friday,
|
|
saturday: saturday ?? this.saturday,
|
|
sunday: sunday ?? this.sunday,
|
|
);
|
|
}
|
|
|
|
factory Schedules.fromDocument(Map<String, dynamic> doc) {
|
|
return Schedules(
|
|
monday: ScheduleEntity.fromDocument(doc['monday']),
|
|
tuesday: ScheduleEntity.fromDocument(doc['tuesday']),
|
|
wednesday: ScheduleEntity.fromDocument(doc['wednesday']),
|
|
thursday: ScheduleEntity.fromDocument(doc['thursday']),
|
|
friday: ScheduleEntity.fromDocument(doc['friday']),
|
|
saturday: ScheduleEntity.fromDocument(doc['saturday']),
|
|
sunday: ScheduleEntity.fromDocument(doc['sunday']),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'monday': monday.toJson(),
|
|
'tuesday': tuesday.toJson(),
|
|
'wednesday': wednesday.toJson(),
|
|
'thursday': thursday.toJson(),
|
|
'friday': friday.toJson(),
|
|
'saturday': saturday.toJson(),
|
|
'sunday': sunday.toJson(),
|
|
};
|
|
}
|
|
|
|
// Produces the array format expected by PATCH /professionals/me/schedules
|
|
// day_of_week: 0=Monday … 6=Sunday (matches backend DB convention)
|
|
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),
|
|
];
|
|
}
|
|
}
|