feat(admin): resource-mode booking flow with a hold countdown

The engine from tasks 06 and 07 could find slots and hold them, but nothing in
the panel could actually book one.

- Search, hold, confirm stay three separate steps because they are three
  separate states: between seeing a slot and taking it the seat is still open,
  and between taking and confirming there is a deadline
- HoldCountdown reads the server's expires_at rather than starting its own
  timer at render: browser clock skew and network latency both cost seconds,
  and those seconds are exactly where a hold is lost. It turns urgent under a
  minute and tells the parent the moment it lapses
- Per-role resource swap offers only the resources the engine returned for that
  same slot. Listing every resource in the branch would let an operator pick
  one that was never free and collect a 409
- An empty result is not an error: the reason code renders as a sentence
  saying what to change
- Confirm requires a doctor and stays disabled until one is chosen — the
  endpoint rejects it anyway, and finding that out after the hold clock has
  been running is the wrong time

Reached from the appointments page as a separate action rather than folded into
the existing form: its search comes from the intersection of resource
calendars, not from one doctor's slots, and merging the two would confuse both.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
hamed
2026-07-31 20:05:12 +03:30
co-authored by Claude Opus 5
parent 4bdacdcc7b
commit 0074162bb1
8 changed files with 571 additions and 16 deletions
@@ -1,6 +1,6 @@
# چک‌لیست — تسک ۰۶ (موتور جستجوی وقت چندمنبعی)
**وضعیت کلی:**بک‌اند، موتور، کارایی، مستندات و UI انتخاب حالت (جریان رزرو ⏳ با مقصد) · **آخرین بازبینی:**
**وضعیت کلی:**تمام‌شده — موتور، کارایی، مستندات، انتخاب حالت و جریان رزرو · **آخرین بازبینی:**
قواعد: [_shared/definition-of-done.md](../_shared/definition-of-done.md) ·
[red-lines.md](../_shared/red-lines.md) · [ui-conventions.md](../_shared/ui-conventions.md)
@@ -67,10 +67,10 @@
| ۴.۱ | انتخاب حالت `resource` + گام | ⚠️ | حالت سوم و «گام جستجوی وقت» به `ScheduleSection` اضافه شد. انتخابگر **استراتژی** ساخته نشد چون استراتژی‌ای در بک‌اند وجود ندارد (ردیف ۱.۲) — منوی خالی بدتر از نبودنش است |
| ۴.۲ | چک‌لیست پیش از ارتقا با ✓/✗ | ✅ | ⭐ «حداقل یک منبع فعال» و «حداقل یک سرویس با بخش» با لینک اصلاح؛ همان شرطی که بک‌اند هم اعمال می‌کند |
| ۴.۳ | تأیید برگشت‌ناپذیری | ✅ | `ConfirmDialog` موجود، حالا با برچسب درست هر سه حالت |
| ۴.۴ | جدول وقت‌ها با ستون «منابع پیشنهادی» | | جریان **رزرو** منبع‌محور در پنل ساخته نشد؛ `POST /appointment-availability` و `assignment` از API کامل‌اند. مقصد: پاس جریان رزرو |
| ۴.۵ | عوض کردن یک منبع → اعتبارسنجی همان زمان | | با ۴.۴ یک بسته است |
| ۴.۶ | `reason` خالی‌بودن با پیام فارسی | | با ۴.۴ یک بسته است |
| ۴.۷ | `assignment` به بیمار نمایش داده نمی‌شود | | با ۴.۴ یک بسته است |
| ۴.۴ | جدول وقت‌ها با ستون «منابع پیشنهادی» | | `ResourceBookingPage` — تاریخ، ساعت، منابع، انتخاب |
| ۴.۵ | عوض کردن یک منبع → گزینه‌های **همان زمان** | | ⭐ فهرست هر نقش فقط منابعی است که موتور برای همان زمان داده؛ فهرست کامل شعبه یعنی انتخابی که ۴۰۹ می‌گیرد |
| ۴.۶ | `reason` خالی‌بودن با پیام فارسی | | `REASON_LABELS` — «بازه را بزرگ‌تر کنید یا شعبهٔ دیگری را امتحان کنید» |
| ۴.۷ | `assignment` به بیمار نمایش داده نمی‌شود | | صفحه پنل‌محور است و همان‌جا هم نوشته شده |
| ۴.۸ | هیچ رنگ/شعاع hard-code | ✅ | فقط `var(--…)` |
| ۴.۹ | دارک‌مود و حالت فشرده | ⚠️ | فقط توکن‌ها؛ بازبینی چشمی انجام نشد |
| ۴.۱۰ | RTL و موبایل | ✅ | کارت‌های حالت روی موبایل تک‌ستونه می‌شوند |