import React, { FC, useRef, forwardRef, useCallback, } from 'react'; import DatePicker from 'react-datepicker'; import 'react-datepicker/dist/react-datepicker.css'; import { useTranslation } from 'react-i18next'; type CustomInputProps = { buttonRef: React.Ref onClick?: () => void; } const CustomInput = forwardRef((props: CustomInputProps) => { const { t } = useTranslation(); return ( ); }); type DateRangePickerProps = { startDate: Date | null endDate: Date | null onChange: (dateList: Date[] | null[]) => void } export const DateRangePicker: FC = (props: DateRangePickerProps) => { const { startDate, endDate, onChange } = props; const buttonRef = useRef(null); const changeHandler = useCallback((dateList: Date[] | null[]) => { if (onChange != null) { const [start, end] = dateList; const isSameTime = (start != null && end != null) && (start.getTime() === end.getTime()); if (isSameTime) { onChange([null, null]); } else { onChange(dateList); } } }, [onChange]); return (
} />
); };