var React = require('react');

var TextBoxOptions = React.createClass({
	componentDidMount: function(){
		this.props.disableSubmitButton(true);
	},
	handleChange: function(){

		var optionsList = [{"text": React.findDOMNode(this.refs.surveyTextBox).value.trim(),"optionId": -1}];
		this.props.submitAnswer(optionsList);
		if(React.findDOMNode(this.refs.surveyTextBox).value.trim()===''){
			this.props.disableSubmitButton(true);
			this.props.updateAnswer(true, false);
		}
		else{
			this.props.disableSubmitButton(false);
			this.props.updateAnswer(true, true);
		}
		// this.props.updateAnswer(true, true);
	},
	render: function(){
		return(<textarea rows="4" style={{width: '100%'}} ref="surveyTextBox" onChange={this.handleChange}></textarea>);
	}
});

module.exports = TextBoxOptions;
