content: import React, { Component } from 'react';
  import 'react-datepicker/dist/react-datepicker.css';
  import { questionCategory } from '../../../utils/enums/questionCategory';
  import Checkbox from '../Question/Checkbox';
  import Radio from '../Question/Radio';
  import Country from '../Question/Country';
  import Textfield from '../Question/Textfield';
  import Number from '../Question/Number';
  import Dropdown from '../Question/Dropdown';
  import DatePick from '../Question/DatePick';
  import Upload from '../Question/Upload';
  import Plus from '../Question/Plus';
  import InfoText from '../Question/InfoText';
  import TextArea from '../Question/TextArea';
  import { taxRulingState } from "../../../utils/enums/taxRulingState";
  
  class Question extends Component {
    constructor(props) {
      super(props);
      this.state = { answer: '' };
    }
  
    bubbleToQuestion(answer) {
      this.props.bubbleToGroup();
      this.setState({ answer });
    }
  
    renderQuestion() {
      switch (parseInt(this.props.question.type)) {
        case questionCategory.checkbox:
          return (
            <Checkbox
              question={this.props.question}
              year={this.props.year}
              bubbleToQuestion={this.bubbleToQuestion.bind(this)}
              questionPlusId={this.props.questionPlusId}
              key={this.props.question.id}
              isDisabled={() => {
                if (window.location.hash == "#ruling") {
                  console.log("testest");
                  return (
                    this.props.currentTaxRulingState >=
                      taxRulingState.modified ||
                    this.props.currentTaxRulingState ==
                      taxRulingState.readyToReview
                  );
                } else {
                  return (
                    (this.props.isReviewingState && !this.props.question.feedback) || this.props.isDisabled
                  );
                }
              }}
            />
          );
        case questionCategory.date:
  
          return (
            <DatePick
              question={this.props.question}
              year={this.props.year}
              bubbleToQuestion={this.bubbleToQuestion.bind(this)}
              questionPlusId={this.props.questionPlusId}
              key={this.props.question.id}
              isDisabled={(this.props.isReviewingState() && !this.props.question.feedback) || this.props.isDisabled()}
            />
          );
        case questionCategory.textfield:
          return (
            <Textfield
              question={this.props.question}
              year={this.props.year}
              bubbleToQuestion={this.bubbleToQuestion.bind(this)}
              questionPlusId={this.props.questionPlusId}
              key={this.props.question.id}
              isDisabled={(this.props.isReviewingState() && !this.props.question.feedback) || this.props.isDisabled()}
            />
          );
        case questionCategory.dropdown:
          return (
            <Dropdown
              question={this.props.question}
              year={this.props.year}
              bubbleToQuestion={this.bubbleToQuestion.bind(this)}
              questionPlusId={this.props.questionPlusId}
              key={this.props.question.id}
              isDisabled={(this.props.isReviewingState() && !this.props.question.feedback) || this.props.isDisabled()}
            />
          );
        case questionCategory.number:
          return (
            <Number
              question={this.props.question}
              year={this.props.year}
              bubbleToQuestion={this.bubbleToQuestion.bind(this)}
              questionPlusId={this.props.questionPlusId}
              key={this.props.question.id}
              isDisabled={(this.props.isReviewingState() && !this.props.question.feedback) || this.props.isDisabled()}
            />
          );
        case questionCategory.radio:
          return (
            <Radio
              question={this.props.question}
              year={this.props.year}
              bubbleToQuestion={this.bubbleToQuestion.bind(this)}
              questionPlusId={this.props.questionPlusId}
              key={this.props.question.id}
              isDisabled={(this.props.isReviewingState() && !this.props.question.feedback) || this.props.isDisabled()}
            />
          );
        case questionCategory.country:
          return (
            <Country
              question={this.props.question}
              year={this.props.year}
              bubbleToQuestion={this.bubbleToQuestion.bind(this)}
              questionPlusId={this.props.questionPlusId}
              key={this.props.question.id}
              isDisabled={(this.props.isReviewingState() && !this.props.question.feedback) || this.props.isDisabled()}
            />
          );
        case questionCategory.upload:
          return (
            <Upload
              question={this.props.question}
              year={this.props.year}
              bubbleToQuestion={this.bubbleToQuestion.bind(this)}
              questionPlusId={this.props.questionPlusId}
              key={this.props.question.id}
              isDisabled={(this.props.isReviewingState() && !this.props.question.feedback) || this.props.isDisabled()}
            />
          );
        case questionCategory.plus:
          return (
            <Plus
              question={this.props.question}
              year={this.props.year}
              bubbleToQuestion={this.bubbleToQuestion.bind(this)}
              questionPlusId={this.props.questionPlusId}
              key={this.props.question.id}
              isDisabled={(this.props.isReviewingState() && !this.props.question.feedback) || this.props.isDisabled()}
            />
          );
        case questionCategory.infoText:
          return (
            <InfoText
              question={this.props.question}
              year={this.props.year}
              questionPlusId={this.props.questionPlusId}
              key={this.props.question.id}
            />
          );
        case questionCategory.textArea:
          return (
            <TextArea
              question={this.props.question}
              year={this.props.year}
              bubbleToQuestion={this.bubbleToQuestion.bind(this)}
              questionPlusId={this.props.questionPlusId}
              key={this.props.question.id}
              isDisabled={(this.props.isReviewingState() && !this.props.question.feedback) || this.props.isDisabled()}
            />
          );
        default:
          return (
            <div key={this.props.question.id} className="questionContainer">
              {' '}{this.props.question.type}{' '}
            </div>
          );
      }
    }
  
    render() {
      let question = this.props.question;
      let _this = this;
  
      if (!question.children) {
        return this.renderQuestion(question);
      }
      return (
        <div className={question.type != questionCategory.plus ? 'childQuestionContainer' : ''}>
          {this.renderQuestion(question)}
          {question.children.map((subQuestion) => {
            if (
              _this.state.answer === subQuestion.condition &&
              (_this.state.answer !== undefined || _this.state.answer !== '')
            ) {
              return (
                <Question
                  key={subQuestion.id}
                  question={subQuestion}
                  year={_this.props.year}
                  bubbleToGroup={_this.props.bubbleToGroup.bind(_this)}
                  questionPlusId={this.props.questionPlusId}
                  dispatch={_this.props.dispatch}
                  isReviewingState={_this.props.isReviewingState}
                  isDisabled={_this.props.isDisabled}
                />
              );
            }
          })}
        </div>
      );
    }
  }
  
  export default Question;
  