From f510c8c415334fa9c94655cf84c552f2c6d6bda0 Mon Sep 17 00:00:00 2001 From: Sergey Elpashev Date: Tue, 6 May 2025 11:26:58 +0300 Subject: [PATCH] feat: cannot set previous dates --- src/components/ModalCalendar.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/ModalCalendar.tsx b/src/components/ModalCalendar.tsx index b5ea2f1..10f573c 100644 --- a/src/components/ModalCalendar.tsx +++ b/src/components/ModalCalendar.tsx @@ -1,7 +1,7 @@ import { cn } from "@/utils/class-merge"; import { ClockIcon } from "@heroicons/react/24/outline"; import { FunctionComponent } from "preact"; -import { Dispatch, StateUpdater, useState } from "preact/hooks"; +import { Dispatch, StateUpdater, useEffect, useState } from "preact/hooks"; import { Calendar, CalendarPassThroughMethodOptions } from "primereact/calendar"; import { FormEvent } from "primereact/ts-helpers"; import Button from "./ui/Button"; @@ -36,6 +36,13 @@ const ModalCalendar: FunctionComponent = ({ ...rest }) => { const [showTime, setShowTime] = useState(false); + const [minDate, setMinDate] = useState(new Date()); + useEffect(() => { + const interval = setInterval(() => { + setMinDate(new Date()); + }, 1000); + return () => clearInterval(interval); + }, []); return ( = ({ onChange={onChange} value={value} hourFormat="24" + minDate={minDate} showTime={showTime} pt={{ root: ({ props }: CalendarPassThroughMethodOptions) => ({