Skip to content

Commit

Permalink
fix: Time picker bug fix (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
praveen5959 authored Dec 18, 2024
1 parent 910fd4f commit fd76cd4
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/components/Header/TimeRange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ const CustomTimeRange: FC<CustomTimeRangeProps> = ({ setOpened, resetToRelative
const onTimeSelect = (key: keyof typeof localSelectedRange, time: string) => {
setLocalSelectedRange((state) => {
const [hours, minutes] = time.split(':').map(Number);
const date = state[key];
date.setHours(hours, minutes, 0, 0);
state[key] = date;
return { ...state };
if (isNaN(hours) || isNaN(minutes)) return state;
const updatedDate = new Date(state[key]);
updatedDate.setHours(hours, minutes, 0, 0);
return { ...state, [key]: updatedDate };
});
};

Expand Down Expand Up @@ -304,7 +304,11 @@ const CustomTimeRange: FC<CustomTimeRangeProps> = ({ setOpened, resetToRelative
}}
renderDay={(date) => highlightDate(date, 'startTime')}
/>
<TimeInput value={startingTime} onChange={(e) => onTimeSelect('startTime', e.currentTarget.value)} />
<TimeInput
error={isStartTimeMoreThenEndTime && 'Start time must be earlier than end time.'}
value={startingTime}
onChange={(e) => onTimeSelect('startTime', e.currentTarget.value)}
/>
</Stack>
<Stack className={classes.datePickerContainer}>
<DatePicker
Expand Down

0 comments on commit fd76cd4

Please sign in to comment.