fix: #15487 select arbitary start time (#15523)

* update for any startdate

* update end time if less than start

---------

Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
This commit is contained in:
VijayandJoe Au-Yeung authored and GitHub committed 2024-06-21 18:25:57 +00:00
1 parent 10f8b40348
commit 765b0b44f8
1 file changed
+9 -2
@@ -408,9 +408,15 @@ const TimeRangeField = ({
isDisabled={disabled}
value={value.start}
menuPlacement="bottom"
max={value.end}
onChange={(option) => {
onChange({ ...value, start: new Date(option?.value as number) });
const newStart = new Date(option?.value as number);
if (newStart >= new Date(value.end)) {
const newEnd = new Date(option?.value as number);
newEnd.setMinutes(newEnd.getMinutes() + INCREMENT);
onChange({ ...value, start: newStart, end: newEnd });
} else {
onChange({ ...value, start: newStart });
}
handleSubmit && handleSubmit(getValues() as AvailabilityFormValues);
}}
/>
@@ -457,6 +463,7 @@ const LazySelect = ({
onMenuOpen={() => {
if (min) filter({ offset: min });
if (max) filter({ limit: max });
if (!min && !max) filter({ offset: 0, limit: 0 });
}}
menuPlacement={menuPlacement}
value={options.find((option) => option.value === dayjs(value).toDate().valueOf())}