fix(doctor): derive booking state from booking_locations
The profile decided "نوبتدهی غیرفعال است" from `doctor.active` alone, while the page already had `booking_locations` — the more precise source, since the backend only returns locations that are genuinely bookable. The two could disagree, and for a doctor bookable only at a clinic they did. A shared `bookingState` helper now drives both the desktop card and the mobile bar: any location means bookable, the label comes from the earliest `next_available_at`, and locations with no capacity yet read as "فعلاً نوبت خالی ندارد" rather than disabled. With no locations at all it falls back to the previous `doctor.active` / `free_turn` fields. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,24 +4,30 @@ import { Button } from "@mui/material";
|
||||
import ItemAppointment from "./ItemAppointment";
|
||||
import ArrowLeftD from "@/components/icons/ArrowLeftD";
|
||||
import Link from "next/link";
|
||||
import { bookingState } from "./bookingState";
|
||||
|
||||
function AppointmentList({ doctor, loading, doctorSlug }) {
|
||||
function AppointmentList({ doctor, loading, doctorSlug, bookingLocations = [] }) {
|
||||
const booking = bookingState(doctor, bookingLocations);
|
||||
return (
|
||||
<>
|
||||
<ul className="hidden sticky top-[122px] sm:top-[150px] mt:top-[178px] lg:top-[206px] lg:flex w-[38%] flex-col justify-start items-center gap-8">
|
||||
{doctor && (
|
||||
<ItemAppointment loading={loading} turn={doctor} key={doctor.id} doctorSlug={doctorSlug} />
|
||||
<ItemAppointment
|
||||
loading={loading}
|
||||
turn={doctor}
|
||||
key={doctor.id}
|
||||
doctorSlug={doctorSlug}
|
||||
booking={booking}
|
||||
/>
|
||||
)}
|
||||
</ul>
|
||||
<div
|
||||
className="fixed lg:hidden bg-[#FFF] border-t border-transparent border-t-[#D7D7D7] border-solid bottom-0 right-0 w-full p-4 flex items-center justify-between"
|
||||
>
|
||||
<p className="text-[#05BA58] text-[11px] font-normal">
|
||||
{doctor?.active === false || !doctor?.free_turn
|
||||
? "نوبتدهی غیرفعال است"
|
||||
: `اولین نوبت آزاد: ${doctor.free_turn}`}
|
||||
{booking.label}
|
||||
</p>
|
||||
{doctor?.active === false ? (
|
||||
{!booking.enabled ? (
|
||||
<Button
|
||||
variant="contained"
|
||||
className="!py-2 !px-4 gap-1 !text-[14px] !font-medium"
|
||||
|
||||
Reference in New Issue
Block a user