import React from 'react';
import _ from 'lodash';
import 'react-dates/initialize';
import {FormGroup} from '../FormGroup';
import {SingleDatePickerInputControl} from './SingleDatePickerInputControl';

export class SingleDatePicker extends FormGroup<any> {
    static propTypes: any = {
        ...FormGroup.propTypes
    };

    static defaultProps = {
        ...FormGroup.defaultProps,
        testAutomationId: 'datePicker'
    };

    filterGroupProps(props) {
        return _.omit(props, [
            'inputProps',
            'hasMomentFormat',
            'hasDateFormat',
            'locale',
            'timeFormat',
            'isValidDate'
        ]);
    }

    renderInput(hasError) {
        return (
            <SingleDatePickerInputControl
                {...this.getSafeProps(this.props)}
                ref="control"
                hasFormGroupContainer
                {...this.getAriaDescProps(hasError)}
            />
        );
    }
}
