fix: compare service days as dates, not raw strings
DateTime.toString() renders "2026-07-13 00:00:00.000Z" while the backend sends "2026-07-13T00:00:00.000Z", so every day comparison was false and no booked slot was ever detected. Both calendars showed fully free days. The client calendar now also treats an unloaded agenda as busy instead of free: rendering a taken slot as available leads straight to a double booking. Note: the client still reads /services/professional/calendar, which returns the *caller's* calendar. There is no endpoint for another professional's agenda, so a client cannot yet see which of that professional's slots are taken. That needs a backend endpoint. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
2c1ba7f6d5
commit
8c6e2ae024
@@ -0,0 +1,14 @@
|
||||
/// Whether a service's `day` field refers to the same calendar day as [day].
|
||||
///
|
||||
/// The backend returns ISO 8601 ("2026-07-13T00:00:00.000Z") while
|
||||
/// `DateTime.toString()` produces a space separator ("2026-07-13 00:00:00.000Z"),
|
||||
/// so comparing the two as raw strings never matched and every booked slot
|
||||
/// rendered as free. Compare parsed calendar dates instead.
|
||||
bool isSameServiceDay(DateTime day, String? serviceDay) {
|
||||
if (serviceDay == null || serviceDay.isEmpty) return false;
|
||||
final parsed = DateTime.tryParse(serviceDay);
|
||||
if (parsed == null) return false;
|
||||
return parsed.year == day.year &&
|
||||
parsed.month == day.month &&
|
||||
parsed.day == day.day;
|
||||
}
|
||||
Reference in New Issue
Block a user