Skip to content

Commit

Permalink
fix start date change not possible in time filter (#2749)
Browse files Browse the repository at this point in the history
* fix start date change not possible in time filter

* use satisfies instead of as
  • Loading branch information
kavinvalli authored Oct 9, 2024
1 parent cfe1b93 commit 5e48cd0
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions web/components/shared/themed/themedTimeFilterShadCN.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,25 +234,29 @@ export function ThemedTimeFilterShadCN({
defaultMonth={date?.from}
selected={date}
onSelect={(newDate) => {
if (newDate?.from && newDate?.to && date?.from && date?.to) {
if (newDate?.from || newDate?.to) {
const newDateRange = {
from: new Date(
newDate.from.getFullYear(),
newDate.from.getMonth(),
newDate.from.getDate(),
date.from.getHours(),
date.from.getMinutes()
),
to: new Date(
newDate.to.getFullYear(),
newDate.to.getMonth(),
newDate.to.getDate(),
date.to.getHours(),
date.to.getMinutes()
),
from: newDate?.from
? new Date(
newDate.from.getFullYear(),
newDate.from.getMonth(),
newDate.from.getDate(),
date?.from?.getHours() ?? 0,
date?.from?.getMinutes() ?? 0
)
: date?.from,
to: newDate?.to
? new Date(
newDate.to.getFullYear(),
newDate.to.getMonth(),
newDate.to.getDate(),
date?.to?.getHours() ?? 23,
date?.to?.getMinutes() ?? 59
)
: date?.to,
};

handleDateChange(newDateRange);
handleDateChange(newDateRange satisfies DateRange);
}
}}
numberOfMonths={2}
Expand Down

0 comments on commit 5e48cd0

Please sign in to comment.