var ForgotPass = React.createClass({
    getInitialState: function () {
        return ({
            formErrors: []
        })

    },
    handleClick: function (e) {
        e.preventDefault()
        console.log(this);
        errors = [];
        if($(emailInput).val() != '')
        {
            $(EmailTemplateEntity).on('EmailTemplatesHasChanged', function(){
                info = EmailTemplateEntity.getEmailResetData();
                console.log(info.inDB);
                if(info.inDB == 1)
                {
                    e = 'login';
                    this.props.handler(e);
                    $(EmailTemplateEntity).off('EmailTemplatesHasChanged');
                }
                else
                {
                    errors.push("We can not complete this operation");
                    this.setState({formErrors: errors});
                }
            }.bind(this))
            EmailTemplateEntity.sendEmailNoId(this.refs.user.getDOMNode().value, 3);
        }
        else
        {
            errors.push("Your Email can not be empty");
            this.setState({formErrors: errors});
        }

    },
    render: function () {
        return (
            <div className="container loginView judgeView">
                <h1 className="title-form">Enter Email to send Password Reset Request</h1>
                <Alert show={this.state.formErrors.length > 0} type="danger" messages={this.state.formErrors}/>
                <form>
                    <div className="form-group">
                        <input ref="user" type="email" className="form-control input-app input-upper" id="emailInput"
                               placeholder="email@example.com"/>
                    </div>

                    <div className="form-group">
                        <div className='input-group full-width'>
                            <button type='submit' id='clickForget' className='btn btn-lightblue btn-block' onClick={this.handleClick}>
                                Send Password Reset Request
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        );
    }
});