import React, {Component} from 'react';
import ReactDOM from 'react-dom';
export default class TerminalSubmit extends Component {

  constructor(props, context){
    super(props, context);
    this.handleSubmit = this.handleSubmit.bind(this);
  }

  handleSubmit(e){
    e.preventDefault();
    let answer = $('#terminal-answer').val();
    // let input = ReactDOM.findDOMNode(this.refs.input).value;
    // let actions = this.props.terminalActions;
    // //setting title input to state
    // actions.setSubmittedInput(input);
    // //deciding if submitted input is same as instruction
    // if(input != this.props.terminalState.currentLevelState.levelInput){
    //   this.props.terminalActions.incorrectSubmission(true);
    // }else{
    //   this.props.terminalActions.incorrectSubmission(false);
    //   actions.setLevelCleared(this.props.terminalState.currentLevelState.level);
    // }
    // //making submitclicked in currentlevel true
    // actions.submitClicked(true);
    let requestObject = {};
    requestObject.vlqId = this.props.currentLevelDetails.vlqId;
    requestObject.userSubmission = answer;
    requestObject.metaData = this.props.currentLevelSubmissionDetails.metaData;
    this.props.VLCommonActions.evaluateVLQAPI(requestObject);
  }

  render() {
    // let currentLevelState = this.props.terminalState.currentLevelState;
    return (
          <div>
            <div className='row' style={{height:'20%', width:'100%'}}>
              <div className='col-xs-offset-1' style={{paddingRight:'20px'}}>
                <div>
                  <p style={{color: '#1A3141'}}>
                    <b>Got Answer?</b>
                  </p>
                  <input
                    className="form-control"
                    id = 'terminal-answer'
                    ref="terminalAnswer"
                    style={{display: 'inline-block',width:'45%'}}/>
                  <button
                    className="btn btn-success"
                    style={{display: 'inline-block',margin: '0 25px'}}
                    onClick={this.handleSubmit}>
                    Submit
                  </button>
                </div>
              </div>
            </div>
          </div>
    );
  }
}
