From c05ac7ca515f2379230241de979072033e9918a8 Mon Sep 17 00:00:00 2001
From: hamed <15238-genius.ha@users.noreply.drupalcode.org>
Date: Thu, 11 Jun 2026 20:00:02 +0330
Subject: [PATCH] feat: add past slot validation to appointment controllers and
update SlotCard component
---
assets/admin/pages/AppointmentsPage.tsx | 19 +++++++++++++++++++
.../Controller/AppointmentController.php | 4 ++++
.../Controller/MyAppointmentsController.php | 4 ++++
3 files changed, 27 insertions(+)
diff --git a/assets/admin/pages/AppointmentsPage.tsx b/assets/admin/pages/AppointmentsPage.tsx
index 5611be06..7aa596a1 100644
--- a/assets/admin/pages/AppointmentsPage.tsx
+++ b/assets/admin/pages/AppointmentsPage.tsx
@@ -292,6 +292,8 @@ function CancelledBadge({ appt }: { appt: Appointment }) {
}
function SlotCard({ slot, queryKey, onBook }: { slot: SlotItem; queryKey: unknown[]; onBook: (slot: SlotItem) => void }) {
+ const isPast = slot.start < Math.floor(Date.now() / 1000);
+
if (!slot.is_available && slot.appointment) {
const a = slot.appointment;
const sm = statusMeta(a.status);
@@ -299,6 +301,7 @@ function SlotCard({ slot, queryKey, onBook }: { slot: SlotItem; queryKey: unknow
+ {slot.cancelled_appointment &&
}
+
+ ⊘ گذشته
+
+
+ );
+ }
+
return (
{slot.cancelled_appointment && }
diff --git a/src/Appointment/Controller/AppointmentController.php b/src/Appointment/Controller/AppointmentController.php
index 4eade752..ab1d19dd 100644
--- a/src/Appointment/Controller/AppointmentController.php
+++ b/src/Appointment/Controller/AppointmentController.php
@@ -173,6 +173,10 @@ class AppointmentController extends BaseController
return $this->error(ErrorCodes::ERR_VALIDATION_001, 'doctor_uuid، slot_start و slot_end الزامی است', 422);
}
+ if ($slotStart < time()) {
+ return $this->error(ErrorCodes::ERR_VALIDATION_001, 'زمان این اسلات گذشته است', 422);
+ }
+
$doctor = $this->doctorRepo->findByUuid($doctorUuid);
if ($doctor === null) {
return $this->error(ErrorCodes::ERR_VALIDATION_002, 'دکتر یافت نشد', 404);
diff --git a/src/Appointment/Controller/MyAppointmentsController.php b/src/Appointment/Controller/MyAppointmentsController.php
index 2315d0e0..c9bd614a 100644
--- a/src/Appointment/Controller/MyAppointmentsController.php
+++ b/src/Appointment/Controller/MyAppointmentsController.php
@@ -45,6 +45,10 @@ class MyAppointmentsController extends BaseController
return $this->error('VALIDATION', 'همه فیلدها الزامی است', 422);
}
+ if ($slotStart < time()) {
+ return $this->error('SLOT_PAST', 'زمان این اسلات گذشته است', 422);
+ }
+
$doctor = $this->doctorRepo->findByUuid($doctorUuid);
if (!$doctor) return $this->error('DOCTOR_NOT_FOUND', 'پزشک یافت نشد', 404);