feat: past and overlapping ooo (#17373)
* feat: past and overlapping ooo * use existing props * added e2e test * disallow duplicates added tests --------- Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
1 parent
3936a0ae94
commit
5af10a2f61
5 files changed
+131
-54
No files matched your search
@@ -21,7 +21,7 @@ function Calendar({
|
||||
}: CalendarProps) {
|
||||
return (
|
||||
<DayPicker
|
||||
fromDate={fromDate || new Date()}
|
||||
fromDate={fromDate}
|
||||
toDate={toDate || undefined}
|
||||
showOutsideDays={showOutsideDays}
|
||||
className={cn("p-3", className)}
|
||||
|
||||
@@ -14,7 +14,7 @@ type DatePickerWithRangeProps = {
|
||||
dates: { startDate: Date; endDate?: Date };
|
||||
onDatesChange: ({ startDate, endDate }: { startDate?: Date; endDate?: Date }) => void;
|
||||
disabled?: boolean;
|
||||
minDate?: Date;
|
||||
minDate?: Date | null;
|
||||
maxDate?: Date;
|
||||
};
|
||||
|
||||
@@ -34,6 +34,7 @@ export function DatePickerWithRange({
|
||||
onDatesChange({ startDate: onChangeValues?.from, endDate: onChangeValues?.to });
|
||||
}
|
||||
}
|
||||
const fromDate = minDate ?? new Date();
|
||||
|
||||
return (
|
||||
<div className={cn("grid gap-2", className)}>
|
||||
@@ -63,7 +64,8 @@ export function DatePickerWithRange({
|
||||
sideOffset={4}>
|
||||
<Calendar
|
||||
initialFocus
|
||||
fromDate={minDate}
|
||||
//When explicitly null, we want past dates to be shown as well, otherwise show only dates passed or from current date
|
||||
fromDate={minDate === null ? undefined : fromDate}
|
||||
toDate={maxDate}
|
||||
mode="range"
|
||||
defaultMonth={dates?.startDate}
|
||||
|
||||
Reference in new issue
Block a user