diff --git a/.claude/prompt/fix-doctor-free-turn-disabled.md b/.claude/prompt/fix-doctor-free-turn-disabled.md new file mode 100644 index 0000000..b07bf04 --- /dev/null +++ b/.claude/prompt/fix-doctor-free-turn-disabled.md @@ -0,0 +1,172 @@ +# رفع نمایش نوبت آزاد و دکمه نوبت برای پزشک با نوبت‌دهی غیرفعال + +## پروژه + +`nobat724_front` (سایت عمومی — فقط نمایش؛ backend از قبل `free_turn` و `active` صحیح برمی‌گرداند) + +## زمینه + +Backend (`clinicpro`) برای هر پزشک دو فیلد می‌فرستد: +- `active` (boolean) = `activeDoctorAppointment && has_schedule` +- `free_turn` (string) = نزدیک‌ترین روز/ساعت کاری (مثل `دوشنبه 09:00–13:00`)، یا اگر نوبت‌دهی آنلاین خاموش باشد `"نوبت‌دهی آنلاین غیرفعال است"`. + +سایت عمومی این دو فیلد را در سه جا نمایش می‌دهد و الان رفتارش ناقص است. + +## مشکل / هدف + +۱. در کارت لیست `/doctors` و در باکس نوبت‌دهی صفحه‌ی پزشک، متن نوبت آزاد باید با پیشوند **«اولین نوبت آزاد:»** نمایش داده شود (مثلاً `اولین نوبت آزاد: دوشنبه 09:00–13:00`). +۲. اگر پزشک نوبت‌دهی آنلاینش خاموش است (`active === false`)، به‌جای `free_turn` باید **«نوبت‌دهی غیرفعال است»** نوشته شود. +۳. در صفحه‌ی پزشک (`/doctor/{uuid}`) بخش «نوبت دهی»، اگر `active === false` دکمه‌ی **«دریافت نوبت»** باید **disabled** شود (نه لینک فعال به `/appointment`). + +## فایل‌های مرتبط + +| فایل | نقش | +|------|-----| +| `app/component/ItemDoctor.js` | کارت پزشک در لیست `/doctors` — متن `free_turn` | +| `components/doctor/appointmentList/ItemAppointment.js` | باکس نوبت‌دهی دسکتاپ صفحه پزشک — متن + دکمه | +| `components/doctor/appointmentList/index.js` | نوار نوبت‌دهی موبایل (`fixed bottom`) — متن + دکمه | + +## وضعیت فعلی + +### `app/component/ItemDoctor.js` (حوالی خط ۸۴) +```jsx + +

+ {doctor?.free_turn} +

+
+``` +مشکل: متن خام `free_turn` بدون پیشوند «اولین نوبت آزاد». + +### `components/doctor/appointmentList/ItemAppointment.js` (خط ۳۶–۵۸) +```jsx +
+
+ + +

+ {turn?.free_turn + ? ` ${turn?.free_turn}` + : "نوبت ندارد"} +

+
+
+ + + +
+``` +مشکل: پیشوند ندارد؛ دکمه فقط با `loading` غیرفعال می‌شود، نه با `active === false`. + +### `components/doctor/appointmentList/index.js` (نوار موبایل، خط ۱۶–۳۴) +```jsx +
+

+ {doctor && doctor?.free_turn} +

+ + + +
+``` +مشکل: پیشوند ندارد؛ دکمه هیچ‌وقت با `active === false` غیرفعال نمی‌شود. + +## وظایف + +### ۱. کارت لیست — `app/component/ItemDoctor.js` + +متن `free_turn` را با پیشوند نشان بده؛ اگر `active` خاموش بود متن «نوبت‌دهی غیرفعال است». + +```jsx +{Number(doctor?.active) && doctor?.free_turn + ? `اولین نوبت آزاد: ${doctor.free_turn}` + : "نوبت‌دهی غیرفعال است"} +``` +رنگ سبز/قرمز موجود حفظ شود (بر اساس `Number(doctor?.active)`). + +### ۲. باکس دسکتاپ — `components/doctor/appointmentList/ItemAppointment.js` + +اول یک متغیر در ابتدای کامپوننت: +```jsx +function ItemAppointment({ turn, loading, doctorSlug }) { + const bookingDisabled = !loading && turn?.active === false; + return ( +``` + +متن: +```jsx +

+ {bookingDisabled || !turn?.free_turn + ? "نوبت‌دهی غیرفعال است" + : `اولین نوبت آزاد: ${turn.free_turn}`} +

+``` + +دکمه — وقتی `bookingDisabled` بود disabled و بدون ``: +```jsx +{bookingDisabled ? ( + +) : ( + + + +)} +``` + +### ۳. نوار موبایل — `components/doctor/appointmentList/index.js` + +متن: +```jsx +

+ {doctor?.active === false || !doctor?.free_turn + ? "نوبت‌دهی غیرفعال است" + : `اولین نوبت آزاد: ${doctor.free_turn}`} +

+``` + +دکمه: +```jsx +{doctor?.active === false ? ( + +) : ( + + + +)} +``` + +## نکات مهم + +- `active` از API نوع boolean است؛ در `ItemDoctor.js` با `Number(doctor?.active)` چک می‌شود (الگوی موجود را نگه‌دار)، در باقی جاها مستقیم `=== false`. +- در حالت `loading` (اسکلتون) نباید «نوبت‌دهی غیرفعال» نشان داده شود؛ برای همین `bookingDisabled = !loading && turn?.active === false`. +- backend از قبل پیام `"نوبت‌دهی آنلاین غیرفعال است"` در `free_turn` می‌فرستد — ولی frontend نباید به متن backend وابسته باشد؛ بر اساس فیلد boolean `active` تصمیم بگیر (پایدارتر). +- تست با پزشک `7db9be49-db71-4ec5-add6-24f890b4ad29` (در DB محلی باید `active_doctor_appointment=0` شود تا غیرفعال شود). پزشک غیرفعال در لیست `/doctors` اصلاً نمی‌آید (فیلتر backend)، پس باگ کارت لیست فقط برای پزشکانی که `active:false` ولی همچنان در نتیجه هستند مهم است. +- بعد از تغییر: `npm run build` بدون خطا. diff --git a/app/component/ItemDoctor.js b/app/component/ItemDoctor.js index aad2116..963a95f 100644 --- a/app/component/ItemDoctor.js +++ b/app/component/ItemDoctor.js @@ -88,7 +88,9 @@ function ItemDoctor({ doctor, loading, setDoctors, priority = false }) { : "bg-[rgba(211,_47,_47,_0.04)] text-[#D32F2F]" }`} > - {doctor?.free_turn} + {Number(doctor?.active) && doctor?.free_turn + ? `اولین نوبت آزاد: ${doctor.free_turn}` + : "نوبت‌دهی غیرفعال است"}

{/* Arrow */} diff --git a/components/doctor/appointmentList/ItemAppointment.js b/components/doctor/appointmentList/ItemAppointment.js index 9b8c2b8..3e69014 100644 --- a/components/doctor/appointmentList/ItemAppointment.js +++ b/components/doctor/appointmentList/ItemAppointment.js @@ -7,6 +7,7 @@ import Link from "next/link"; import DoctorAvatar from "@/app/component/DoctorAvatar"; function ItemAppointment({ turn, loading, doctorSlug }) { + const bookingDisabled = !loading && turn?.active === false; return (
  • - {turn?.free_turn - ? ` ${turn?.free_turn}` - : "نوبت ندارد"} + {bookingDisabled || !turn?.free_turn + ? "نوبت‌دهی غیرفعال است" + : `اولین نوبت آزاد: ${turn.free_turn}`}

    - + {bookingDisabled ? ( - + ) : ( + + + + )}
  • ); diff --git a/components/doctor/appointmentList/index.js b/components/doctor/appointmentList/index.js index 8d945d9..f62bbc1 100644 --- a/components/doctor/appointmentList/index.js +++ b/components/doctor/appointmentList/index.js @@ -18,19 +18,31 @@ function AppointmentList({ doctor, loading, doctorSlug }) { border-solid bottom-0 right-0 w-full p-4 flex items-center justify-between" >

    - {doctor && doctor?.free_turn} + {doctor?.active === false || !doctor?.free_turn + ? "نوبت‌دهی غیرفعال است" + : `اولین نوبت آزاد: ${doctor.free_turn}`}

    - + {doctor?.active === false ? ( - + ) : ( + + + + )} );