feat(admin): resource booking mode with a readiness guard
Task 06's engine could only be switched on through the API, and nothing checked whether the environment was ready for it. Since the mode choice is irreversible, picking it with no resources defined would lock a clinic into a state where no appointment is ever computable. Backend now refuses that: resource mode requires at least one active resource, with a message that says what to define first. Same shape as the existing service-mode guard, applied on both save paths. The panel shows the same conditions as a ✓/✗ list before the choice is made, each unmet one linking to where it gets fixed — a 422 after an irreversible decision is the wrong place to learn about a prerequisite. Also adds the search step (minimum 5 minutes) and extends the existing mode cards to three rather than building a parallel component. No strategy picker: task 06 never built the strategies, and an empty menu reads worse than an absent one. GET /api/v1/service-items now returns has_segments, computed with one aggregate query for the whole list rather than one per service. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -46,6 +46,7 @@ class ClinicServiceController extends BaseController
|
||||
private readonly TariffRepository $tariffRepo,
|
||||
private readonly TariffService $tariffService,
|
||||
private readonly InventoryPackageRepository $packageRepo,
|
||||
private readonly \App\Appointment\Plan\Repository\SegmentTemplateRepository $segmentRepo,
|
||||
private readonly InventoryItemRepository $inventoryItemRepo,
|
||||
private readonly ServiceItemAuditService $auditService,
|
||||
private readonly ServiceItemAuditLogRepository $auditLogRepo,
|
||||
@@ -76,11 +77,18 @@ class ClinicServiceController extends BaseController
|
||||
array_map(fn(ServiceItem $i) => $i->getInventoryPackageId(), $items)
|
||||
);
|
||||
|
||||
return array_map(function (ServiceItem $i) use ($packages) {
|
||||
// یک کوئری برای همهٔ سرویسها؛ تنظیمات نوبتدهی از همین میفهمد آمادگیِ حالت
|
||||
// منبعمحور هست یا نه، بدون اینکه per سرویس بپرسد.
|
||||
$hasSegments = $this->segmentRepo->hasSegmentsMap(
|
||||
array_map(fn(ServiceItem $i) => (int) $i->getId(), $items)
|
||||
);
|
||||
|
||||
return array_map(function (ServiceItem $i) use ($packages, $hasSegments) {
|
||||
$row = $i->toArray();
|
||||
$package = $packages[$i->getInventoryPackageId()] ?? null;
|
||||
$row['inventory_package_uuid'] = $package?->getUuid();
|
||||
$row['inventory_package_title'] = $package?->getTitle();
|
||||
$row['has_segments'] = $hasSegments[(int) $i->getId()] ?? false;
|
||||
|
||||
return $row;
|
||||
}, $items);
|
||||
|
||||
Reference in New Issue
Block a user