handle disable time before start_time
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user