Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WEB-670] fix: date filter modal selection #3913

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions web/components/core/filters/date-filter-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export const DateFilterModal: React.FC<Props> = ({ title, handleClose, isOpen, o
handleClose();
};

const isInvalid = watch("filterType") === "range" ? new Date(watch("date1")) > new Date(watch("date2")) : false;
const date1 = watch("date1");
const date2 = watch("date2");

const isInvalid = watch("filterType") === "range" ? new Date(date1) > new Date(date2) : false;

return (
<Transition.Root show={isOpen} as={Fragment}>
Expand Down Expand Up @@ -91,7 +94,10 @@ export const DateFilterModal: React.FC<Props> = ({ title, handleClose, isOpen, o
<DayPicker
selected={value ? new Date(value) : undefined}
defaultMonth={value ? new Date(value) : undefined}
onSelect={(date) => onChange(date)}
onSelect={(date) => {
if (!date) return;
onChange(date);
}}
mode="single"
disabled={[{ after: new Date(watch("date2")) }]}
className="border border-custom-border-200 p-3 rounded-md"
Expand All @@ -106,7 +112,10 @@ export const DateFilterModal: React.FC<Props> = ({ title, handleClose, isOpen, o
<DayPicker
selected={value ? new Date(value) : undefined}
defaultMonth={value ? new Date(value) : undefined}
onSelect={(date) => onChange(date)}
onSelect={(date) => {
if (!date) return;
onChange(date);
}}
mode="single"
disabled={[{ before: new Date(watch("date1")) }]}
className="border border-custom-border-200 p-3 rounded-md"
Expand Down
Loading