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())} />