Files
nobat724_front/components/doctor/appointmentList/ItemAppointment.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

76 lines
2.8 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.
import CircularLoading from "@/app/component/loading/Circular";
import TextLoading from "@/app/component/loading/Text";
import ArrowLeftD from "@/components/icons/ArrowLeftD";
import GreenCalendarTurn from "@/components/icons/GreenCalendarTurn";
import { Button } from "@mui/material";
import Link from "next/link";
import DoctorAvatar from "@/app/component/DoctorAvatar";
import { bookingState } from "./bookingState";
function ItemAppointment({ turn, loading, doctorSlug, booking }) {
const state = booking ?? bookingState(turn, []);
const bookingDisabled = !loading && !state.enabled;
return (
<li
key={turn.id}
className="py-4 w-full px-6 bg-[#FFF] border border-solid border-[#EFEFEF] rounded-lg"
>
<p className="text-[#3B3B3B] text-[20px] font-bold">نوبت دهی</p>
<span className="block w-full h-px bg-[#EFEFEF] my-4"></span>
<div className="flex items-center justify-start gap-3">
<CircularLoading width={56} height={56} loading={loading}>
<DoctorAvatar doctor={turn} size={56} />
</CircularLoading>
<div className="flex flex-col items-start justify-center gap-2">
<TextLoading width={60} height={15} loading={loading}>
<p className="text-[#3B3B3B] text-[14px] font-bold">{turn?.name}</p>
</TextLoading>
<TextLoading width={65} height={15} loading={loading}>
<p className="text-[#525252] text-[14px] font-medium">
تخصص:
{turn?.specialties?.map(
(item, idx) =>
`${item.name} ${turn.specialties.length === idx + 1 ? "" : "|"} `
)}
</p>
</TextLoading>
</div>
</div>
<div className="flex mt-5 gap-2 items-center justify-between">
<div className="flex items-start justify-start gap-1">
<GreenCalendarTurn />
<TextLoading width={100} height={15} loading={loading}>
<p className="text-[#05BA58] text-[12px] font-medium">
{state.label}
</p>
</TextLoading>
</div>
{bookingDisabled ? (
<Button
variant="contained"
className="!py-2 !px-3 xl:!px-6 gap-1"
disabled
>
نوبتدهی غیرفعال
</Button>
) : (
<Link href={loading ? "#" : `/appointment/${doctorSlug}`}>
<Button
variant="contained"
className="!py-2 !px-3 xl:!px-6 gap-1"
disabled={loading}
>
دریافت نوبت
<div className="w-[20px] h-[20px]">
<ArrowLeftD />
</div>
</Button>
</Link>
)}
</div>
</li>
);
}
export default ItemAppointment;