diff --git a/client/src/components/DateTimeInput.tsx b/client/src/components/DateTimeInput.tsx index 9b58110..aa29148 100644 --- a/client/src/components/DateTimeInput.tsx +++ b/client/src/components/DateTimeInput.tsx @@ -11,15 +11,21 @@ export const DateTimeInput = ({ value, onChange }: Props) => { const handleDateChange = (e: Event) => { const target = e.target as HTMLInputElement const value = target.value + const newDate = new Date(`${value || splitValue[0]} ${splitValue[1]}`) - onChange(new Date(`${value} ${splitValue[1]}`)) + if (!isNaN(newDate.getTime())) { + onChange(newDate) + } } const handleTimeChange = (e: Event) => { const target = e.target as HTMLInputElement const value = target.value + const newDate = new Date(`${splitValue[0]} ${value || splitValue[1]}`) - onChange(new Date(`${splitValue[0]} ${value}`)) + if (!isNaN(newDate.getTime())) { + onChange(newDate) + } } return (