import React, { Component } from 'react';
import BlockInp from '@containers/BlockInpContainer';
import { connect } from "react-redux";
import {  CLEARMENSTRUATIONTEXTDATA, } from '@store/types/menstruationHistory';
import store from '@store';
class MenstruationHistory extends Component {
  constructor(props) {
    super(props)
    this.state = {
      isShowSexInput: true
    }
  }


  componentWillReceiveProps(nextProps) {
    // console.log(nextProps.patInfoData.patInfoData[3].value);
    if (nextProps.patInfoData.patInfoData[3].value === 1) {
      this.setState({
        isShowSexInput: false
      })     
    } else {
      this.setState({
        isShowSexInput: true
      })
    }
    // store.dispatch({
    //   type: CLEARMENSTRUATIONTEXTDATA,
    // });
  }

  render() {
    const { value, isRead } = this.props;
    return(
      this.state.isShowSexInput?(<BlockInp title='月经史' boxMark='17' value={value} isRead={isRead}></BlockInp>) : null
    );
  }
}

function mapStateToProps(state) {
  const { menstruationHistory } = state;

  return {
    value: menstruationHistory && menstruationHistory.saveText[0],
    patInfoData: state.patInfo
  }
}
function mapDispatchToProps(dispatch, store) {
  return {
  }
}

const MenstruationHistoryCont = connect(
  mapStateToProps,
  mapDispatchToProps
)(MenstruationHistory);

export default MenstruationHistoryCont;