import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; import MediaQuery from 'react-responsive'; import moment from 'moment'; import { Button, Col, Collapse, CustomInput, FormGroup, Input, Label, Row, InputGroupAddon, InputGroup } from 'reactstrap'; import { gettext } from '../../utils/constants'; import DateTimePicker from '../../components/date-and-time-picker'; const { repo_name, search_repo } = window.search.pageOptions; class AdvancedSearch extends React.Component { constructor(props) { super(props); } getFileTypesList = (fileTypes) => { const fileTypeItems = [gettext('Text'), gettext('Document'), gettext('Image'), gettext('Video'), gettext('Audio'), 'PDF', 'Markdown']; let ftype = []; for (let i = 0, len = fileTypes.length; i < len; i++) { if (fileTypes[i]) { ftype.push(fileTypeItems[i]); } } return ftype; }; disabledStartDate = (startValue) => { if (!startValue) { return false; } const isAfterToday = startValue.isAfter(moment(), 'day'); const { time_to } = this.props.stateAndValues; const endValue = time_to; if (!endValue) { return isAfterToday; } return startValue.isAfter(endValue) || isAfterToday; }; disabledEndDate = (endValue) => { if (!endValue) { return false; } const isAfterToday = endValue.isAfter(moment(), 'day'); const { time_from } = this.props.stateAndValues; const startValue = time_from; if (!startValue) { return isAfterToday; } return endValue.isBefore(startValue) || isAfterToday; }; render() { const { stateAndValues } = this.props; const { errorDateMsg, errorSizeMsg } = stateAndValues; if (stateAndValues.isShowSearchFilter) { const { size_from, size_to, time_from, time_to, search_repo, fileTypeItemsStatus } = stateAndValues; const fileTypes = this.getFileTypesList(fileTypeItemsStatus); const typesLength = fileTypes.length; return (