handle disable time before start_time

This commit is contained in:
Ehsan
2024-10-02 14:16:49 +03:30
parent 92e2dd49e0
commit a98ce35b33
2 changed files with 20 additions and 5 deletions
@@ -27,7 +27,19 @@ function Form() {
...data,
[name]: value,
});
console.log(data);
const handleDisableHours = (e, n) => {
if (data.start_time === "00:00" && n === "end_time") return true;
if (data.start_time !== "00:00" && n === "end_time") {
const hourSelected = data.start_time
? +data.start_time.split(":")[0]
: false;
const hours = e.$H;
return hourSelected + 1 > hours;
}
};
// console.log(data);
return (
<div className="flex flex-col w-full-content">
@@ -62,20 +74,22 @@ function Form() {
</ContentText>
<ContentText text="زمان شروع">
<TimePickerInput
handleDisableHours={handleDisableHours}
placeholder="انتخاب کنید..."
changeData={changeData}
data={data.start_time}
icon={<ClockP />}
name="start_time"
data={data}
/>
</ContentText>
<ContentText text="زمان پایان">
<TimePickerInput
handleDisableHours={handleDisableHours}
placeholder="انتخاب کنید..."
changeData={changeData}
data={data.end_time}
icon={<ClockP />}
name="end_time"
data={data}
/>
</ContentText>
<Button