import React, { useState } from 'react' import { DateRangePicker, DateRangePickerProps } from 'react-date-range' import useTheme from '../use-theme' import { styles } from './styles' import useScale, { withScale } from '../use-scale' interface Props { className?: string disabledDates?: Array minDate?: Date maxDate?: Date initialStartDate?: Date initialEndDate?: Date color?: string onChange: (range: any) => void } const defaultProps = { initialStartDate: new Date(), initialEndDate: new Date() } export type DateRangeProps = Props & typeof defaultProps & DateRangePickerProps const background = "\"data:image/svg+xml;utf8,\"" const DateRange: React.FC> = ({ disabledDates, minDate, maxDate, className, initialStartDate, initialEndDate, color, onChange, ...props }) => { const theme = useTheme() const { SCALES } = useScale() const [selectionRange, setSelectionRange] = useState({ startDate: initialStartDate, endDate: initialEndDate, key: 'selection', color: color || theme.palette.success }) const onChangeHandler = (range: any) => { setSelectionRange(range.selection) onChange(range) } return ( <> ) } DateRange.defaultProps = defaultProps const Button = withScale(DateRange) export default Button