/**
 * imui.Datepicker - WeekOper
 * @author riverhan
 * @data 2016-8-10
 */
import React from 'react';
import PropTypes from 'prop-types';

class WeekOper extends React.Component {
  static propTypes = {
    day: PropTypes.object,
    onClickPrevMonth: PropTypes.func.isRequired,
    onClickNextMonth: PropTypes.func.isRequired
  };

  static defaultProps = {
    day: new Date()
  };

  handleClickPrev = () => {
    this.props.onClickPrevMonth();
  };

  handleClickNext = () => {
    this.props.onClickNextMonth();
  };

  render() {
    const date = this.props.day;
    const year = date.getFullYear();
    const month = date.getMonth() + 1;
    const monthStr = `${year}年${month}月`;

    return (
      <div
        className="im-dp-op"
      >
        <span className="im-dp-monthcur">{monthStr}</span>
        <span
          className="im-dp-op-icon im-dp-icon--prev"
          onClick={this.handleClickPrev}
        >‹</span>
        <span
          className="im-dp-op-icon im-dp-icon--next"
          onClick={this.handleClickNext}
        >›</span>
      </div>
    );
  }
}

export default WeekOper;
