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:
@@ -5,9 +5,11 @@ 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 }) {
|
||||
const bookingDisabled = !loading && turn?.active === false;
|
||||
function ItemAppointment({ turn, loading, doctorSlug, booking }) {
|
||||
const state = booking ?? bookingState(turn, []);
|
||||
const bookingDisabled = !loading && !state.enabled;
|
||||
return (
|
||||
<li
|
||||
key={turn.id}
|
||||
@@ -39,9 +41,7 @@ function ItemAppointment({ turn, loading, doctorSlug }) {
|
||||
<GreenCalendarTurn />
|
||||
<TextLoading width={100} height={15} loading={loading}>
|
||||
<p className="text-[#05BA58] text-[12px] font-medium">
|
||||
{bookingDisabled || !turn?.free_turn
|
||||
? "نوبتدهی غیرفعال است"
|
||||
: `اولین نوبت آزاد: ${turn.free_turn}`}
|
||||
{state.label}
|
||||
</p>
|
||||
</TextLoading>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user