import * as React from 'react';
import { DatePicker, InputText } from '@personio/ui-components';

export class DatePickerDemo extends React.Component {
  datePickerInstance: any

  componentDidMount() {
    this.renderDatePicker();
  }

  inputRef = React.createRef();

  onDateChange = (val) => {
    console.log(val);
  }

  onTitleClick = () => {
    console.log('title clicked');
  }

  renderDatePicker = (): void => {
    const options = {
      title: 'Go Back',
      onTitleClick: this.onTitleClick,
      onChange: this.onDateChange,
      closeOnSelectDate: false,
    };

    this.datePickerInstance = new DatePicker(this.inputRef.current.ref, options);
  }


  render() {
    return (<InputText ref={this.inputRef} />);
  }
}
