shlink-web-client/src/utils/DateRangeRow.js

44 lines
1.1 KiB
JavaScript
Raw Normal View History

import React from 'react';
import PropTypes from 'prop-types';
import DateInput from './DateInput';
import './DateRangeRow.scss';
const dateType = PropTypes.oneOfType([ PropTypes.string, PropTypes.object ]);
const propTypes = {
startDate: dateType,
endDate: dateType,
2020-01-14 22:12:30 +03:00
onStartDateChange: PropTypes.func.isRequired,
onEndDateChange: PropTypes.func.isRequired,
2020-04-10 13:25:06 +03:00
disabled: PropTypes.bool,
};
2020-04-10 13:25:06 +03:00
const DateRangeRow = ({ startDate, endDate, onStartDateChange, onEndDateChange, disabled = false }) => (
<div className="row">
2020-04-04 00:00:57 +03:00
<div className="col-md-6">
<DateInput
selected={startDate}
placeholderText="Since"
isClearable
maxDate={endDate}
2020-04-10 13:25:06 +03:00
disabled={disabled}
2020-01-14 22:12:30 +03:00
onChange={onStartDateChange}
/>
</div>
2020-04-04 00:00:57 +03:00
<div className="col-md-6">
<DateInput
className="date-range-row__date-input"
selected={endDate}
placeholderText="Until"
isClearable
minDate={startDate}
2020-04-10 13:25:06 +03:00
disabled={disabled}
onChange={onEndDateChange}
/>
</div>
</div>
);
DateRangeRow.propTypes = propTypes;
export default DateRangeRow;