feat(booking): show only locations that can actually be booked that day

The site offered a "personal practice" for a doctor who has no personal address
at all — the schedule existed but its shifts pointed at the clinic's address, so
there was nowhere to go. The backend now filters those out; this consumes the
filtered contract and adds the per-day dimension.

- getBookingLocations takes an optional date and the appointment page refetches
  on it, merging available_on_date into the existing list rather than replacing
  it, so browsing the calendar never resets the user's choice.
- The browsed day had to be lifted out of the Date step: selectedDate is only
  set once a slot is confirmed, far too late to drive availability.
- A location closed on the chosen day renders disabled with «در این روز نوبت
  ندارد», and when every location is closed the step says so instead of showing
  an empty slot list. If the already-selected location closes, a notice appears
  with a link back to the picker — silently showing nothing was the failure mode
  worth avoiding.
- Doctor profile: workLocation in the Physician JSON-LD is limited to addresses
  that appear in booking_locations, since schema.org presents them as places a
  patient can attend. The address card still lists the others — they are real
  practice details — tagged «بدون نوبت‌دهی آنلاین».

Verified end-to-end with a temporary unused address on the test doctor: the
visible card listed both and tagged the unused one, while workLocation carried
only the bookable one. The row was removed afterwards.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
hamed
2026-07-18 14:44:49 +03:30
co-authored by Claude Opus 4.8
parent f4dd73e55e
commit b37096048c
11 changed files with 294 additions and 18 deletions
+11 -2
View File
@@ -129,6 +129,14 @@ async function Doctor({ params }) {
? await Promise.all([getDoctorAddresses(doctor.id), getBookingLocations(doctor.uuid)])
: [[], []];
// آدرسی که در هیچ برنامهٔ نوبت‌دهی استفاده نشده، محل مراجعه نیست. در کارت
// «موقعیت مکانی» می‌ماند (اطلاعات واقعی مطب است) ولی به JSON-LD نمی‌رود، چون
// schema.org آن را محلی قابل‌مراجعه اعلام می‌کند.
const bookableAddressUuids = new Set(
bookingLocations.map((l) => l.location_uuid).filter(Boolean)
);
const bookableAddresses = addresses.filter((a) => bookableAddressUuids.has(a.uuid));
// ساعات کاری per-location است؛ با uuid آدرس به هر محل وصل می‌شود.
const openingHoursByLocation = bookingLocations.reduce((acc, location) => {
if (location.location_uuid && location.opening_hours?.length) {
@@ -191,8 +199,8 @@ async function Doctor({ params }) {
}),
})),
}),
...(addresses.length > 0 && {
workLocation: addresses.map((addr) => ({
...(bookableAddresses.length > 0 && {
workLocation: bookableAddresses.map((addr) => ({
"@type": "MedicalClinic",
name: addr.clinic_name || addr.name || `مطب دکتر ${doctor.name}`,
address: {
@@ -258,6 +266,7 @@ async function Doctor({ params }) {
comments={comments}
rateAggregate={rateAggregate}
addresses={addresses}
bookableAddressUuids={[...bookableAddressUuids]}
slug={slug}
/>
</Layout>