import React from 'react'; import { DATE_RANGE_OPTIONS, CUSTOM_RANGE } from 'App/dateRange' import Select from 'Shared/Select'; import Period, { LAST_7_DAYS } from 'Types/app/period'; import { components } from 'react-select'; import DateRangePopup from 'Shared/DateRangeDropdown/DateRangePopup'; import OutsideClickDetectingDiv from 'Shared/OutsideClickDetectingDiv'; interface Props { period: any, onChange: (data: any) => void; } function SelectDateRange(props: Props) { const [isCustom, setIsCustom] = React.useState(false); const { period } = props; const selectedValue = DATE_RANGE_OPTIONS.find(obj => obj.value === period.rangeName) const onChange = (value: any) => { if (value === CUSTOM_RANGE) { setIsCustom(true); } else { props.onChange(new Period({ rangeName: value })); } } const onApplyDateRange = (value: any) => { props.onChange(new Period({ rangeName: CUSTOM_RANGE, start: value.start, end: value.end })); setIsCustom(false); } return (