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>
57 lines
1.7 KiB
JavaScript
57 lines
1.7 KiB
JavaScript
"use client";
|
||
|
||
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, 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}
|
||
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">
|
||
{booking.label}
|
||
</p>
|
||
{!booking.enabled ? (
|
||
<Button
|
||
variant="contained"
|
||
className="!py-2 !px-4 gap-1 !text-[14px] !font-medium"
|
||
disabled
|
||
>
|
||
نوبتدهی غیرفعال
|
||
</Button>
|
||
) : (
|
||
<Link href={`/appointment/${doctorSlug}`}>
|
||
<Button
|
||
variant="contained"
|
||
className="!py-2 !px-4 gap-1 !text-[14px] !font-medium"
|
||
>
|
||
دریافت نوبت
|
||
<div className="w-[20px] h-[20px]">
|
||
<ArrowLeftD />
|
||
</div>
|
||
</Button>
|
||
</Link>
|
||
)}
|
||
</div>
|
||
</>
|
||
);
|
||
}
|
||
|
||
export default AppointmentList;
|