{"size": 1710, "ext": "js", "max_stars_repo_path": "src/components/Utils/DataPickerBetween.js", "max_stars_repo_name": "RafaelSilva-si/Admin-Dy", "max_stars_repo_stars_event_min_datetime": "2022-03-11T18:50:51.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-25T13:00:48.000Z", "max_issues_repo_path": "src/components/Utils/DataPickerBetween.js", "max_issues_repo_name": "RafaelSilva-si/Admin-Dy", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/Utils/DataPickerBetween.js", "max_forks_repo_name": "RafaelSilva-si/Admin-Dy", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.7826086957, "max_line_length": 75, "alphanum_fraction": 0.7245614035}
import React from 'react';
import moment from 'moment';
import { FormGroup, InputGroup, InputGroupAddon, Label } from 'reactstrap';
import PropTypes from '../../lib/utils/propTypes';
import DatePicker from './DatePicker';

const DataPickerBetween = ({
	middleText,
	firstOnChange,
	firstSelect,
	secondOnChange,
	secondSelect,
	label,
	first,
	second,
	firstPlaceholder,
	secondPlaceholder,
	required,
	...rest
}) => (
	<FormGroup {...rest}>
		<Label className={required ? 'required' : ''}>{label}</Label>
		<InputGroup>
			<DatePicker
				handleChange={firstOnChange}
				startDate={firstSelect}
				maxDate={new Date(moment(secondSelect, 'DD/MM/YYYY HH:mm Z'))}
				placeholderText={firstPlaceholder}
				required={required}
				{...first}
			/>
			<InputGroupAddon addonType="prepend">{middleText}</InputGroupAddon>
			<DatePicker
				handleChange={secondOnChange}
				startDate={secondSelect}
				minDate={new Date(moment(firstSelect, 'DD/MM/YYYY HH:mm Z'))}
				placeholderText={secondPlaceholder}
				required={required}
				{...second}
			/>
		</InputGroup>
	</FormGroup>
);

DataPickerBetween.propTypes = {
	middleText: PropTypes.string,
	firstOnChange: PropTypes.func.isRequired,
	firstSelect: PropTypes.date.isRequired,
	secondOnChange: PropTypes.func.isRequired,
	secondSelect: PropTypes.date.isRequired,
	label: PropTypes.string.isRequired,
	firstPlaceholder: PropTypes.string,
	secondPlaceholder: PropTypes.string,
	first: PropTypes.shape({}),
	second: PropTypes.shape({}),
	required: PropTypes.bool,
};

DataPickerBetween.defaultProps = {
	middleText: 'até',
	firstPlaceholder: 'início',
	secondPlaceholder: 'fim',
	first: {},
	second: {},
	required: false,
};

export default DataPickerBetween;
