2020-08-31 19:38:27 +03:00
|
|
|
import moment from 'moment';
|
2020-12-15 00:58:15 +03:00
|
|
|
import DateInput from '../DateInput';
|
|
|
|
import { DateRange } from './types';
|
2020-01-14 21:59:25 +03:00
|
|
|
|
2020-12-15 00:58:15 +03:00
|
|
|
interface DateRangeRowProps extends DateRange {
|
2020-08-31 19:38:27 +03:00
|
|
|
onStartDateChange: (date: moment.Moment | null) => void;
|
|
|
|
onEndDateChange: (date: moment.Moment | null) => void;
|
|
|
|
disabled?: boolean;
|
|
|
|
}
|
2020-01-14 21:59:25 +03:00
|
|
|
|
2020-08-31 19:38:27 +03:00
|
|
|
const DateRangeRow = (
|
|
|
|
{ startDate = null, endDate = null, disabled = false, onStartDateChange, onEndDateChange }: DateRangeRowProps,
|
|
|
|
) => (
|
2020-01-14 21:59:25 +03:00
|
|
|
<div className="row">
|
2020-04-04 00:00:57 +03:00
|
|
|
<div className="col-md-6">
|
2020-01-14 21:59:25 +03:00
|
|
|
<DateInput
|
|
|
|
selected={startDate}
|
2020-12-15 00:58:15 +03:00
|
|
|
placeholderText="Since..."
|
2020-01-14 21:59:25 +03:00
|
|
|
isClearable
|
2020-08-31 19:38:27 +03:00
|
|
|
maxDate={endDate ?? undefined}
|
2020-04-10 13:25:06 +03:00
|
|
|
disabled={disabled}
|
2020-01-14 22:12:30 +03:00
|
|
|
onChange={onStartDateChange}
|
2020-01-14 21:59:25 +03:00
|
|
|
/>
|
|
|
|
</div>
|
2020-04-04 00:00:57 +03:00
|
|
|
<div className="col-md-6">
|
2020-01-14 21:59:25 +03:00
|
|
|
<DateInput
|
2020-12-12 18:55:01 +03:00
|
|
|
className="mt-2 mt-md-0"
|
2020-01-14 21:59:25 +03:00
|
|
|
selected={endDate}
|
2020-12-15 00:58:15 +03:00
|
|
|
placeholderText="Until..."
|
2020-01-14 21:59:25 +03:00
|
|
|
isClearable
|
2020-08-31 19:38:27 +03:00
|
|
|
minDate={startDate ?? undefined}
|
2020-04-10 13:25:06 +03:00
|
|
|
disabled={disabled}
|
2020-01-14 21:59:25 +03:00
|
|
|
onChange={onEndDateChange}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
|
|
|
export default DateRangeRow;
|