Files
nobat724_front/components/doctor/appointmentList/index.js
hamedandClaude Fable 5 36816eded2 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>
2026-07-18 16:25:37 +03:30

57 lines
1.7 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"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;