From c22d82f8c5884c6d532d98cedc507603b42a94f7 Mon Sep 17 00:00:00 2001 From: saridsa2 Date: Thu, 16 Apr 2026 05:41:46 +0530 Subject: [PATCH] fix(dates): block past-date selection in appointment + clinic holiday pickers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug 556 triggered a broader audit of every date input in the app: - appointment-form DatePicker now has minValue=today(getLocalTimeZone()) — can't book or reschedule into the past (tightens bug 555 at the input layer too; the past-slot filter in masterdata service still handles the hour-granularity) - clinic-form holiday date picker gets the same — can't observe a holiday that already passed Audit complete: - enquiry-form follow-up date: already had min=today (bug 556 fix) - appointment-form: fixed here - clinic-form holidays: fixed here - my-performance date filter: past valid (reports over history) - campaign-edit start/end: past valid (historical campaigns) --- src/components/call-desk/appointment-form.tsx | 7 ++++++- src/components/forms/clinic-form.tsx | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/call-desk/appointment-form.tsx b/src/components/call-desk/appointment-form.tsx index e1c2142..172cb92 100644 --- a/src/components/call-desk/appointment-form.tsx +++ b/src/components/call-desk/appointment-form.tsx @@ -6,7 +6,7 @@ import { Select } from '@/components/base/select/select'; import { TextArea } from '@/components/base/textarea/textarea'; import { Button } from '@/components/base/buttons/button'; import { DatePicker } from '@/components/application/date-picker/date-picker'; -import { parseDate } from '@internationalized/date'; +import { parseDate, today, getLocalTimeZone } from '@internationalized/date'; import { apiClient } from '@/lib/api-client'; import { cx } from '@/utils/cx'; import { notify } from '@/lib/toast'; @@ -586,6 +586,11 @@ export const AppointmentForm = ({ onChange={(val) => setDate(val ? val.toString() : '')} granularity="day" isDisabled={readOnly || !doctor} + // Block past dates — appointments can't be booked or + // rescheduled into the past. React Aria's DatePicker + // honours minValue in both the calendar grid and the + // typed-input fallback. + minValue={today(getLocalTimeZone())} /> diff --git a/src/components/forms/clinic-form.tsx b/src/components/forms/clinic-form.tsx index eaba71d..f1a8506 100644 --- a/src/components/forms/clinic-form.tsx +++ b/src/components/forms/clinic-form.tsx @@ -399,6 +399,9 @@ export const ClinicForm = ({ value, onChange }: ClinicFormProps) => { onChange={(dv: DateValue | null) => updateHoliday(idx, { date: dv ? dv.toString() : '' }) } + // Holidays must be today or in the future — you + // can't observe a holiday that already passed. + minValue={today(getLocalTimeZone())} />