var Api = require('./api.js').Api; var App = require('./app.js'); var classNames = require('classnames'); module.exports.SignupForm = React.createClass({ getInitialState: function() { return {'hideMsg': true, 'msg': '', 'msgOk': false, 'password': '', 'email': ''}; }, handleSubmit: function(e) { Api.Call('SIGNUP', { 'password': this.state.password, 'email': this.state.email }, function(err, status, data) { if (err) { console.error(err, data); this.displayMessage(App.errorCodeToMessage(err.code), false); return; } this.displayMessage('Thank You. Your account is being confirmed. Check your mailbox soon', true); this.props.onSuccess(data.token); }.bind(this)); e.preventDefault(); }, handlePasswordChange: function(event) { this.setState({'password': event.target.value}); }, handleEmailChange: function(event) { this.setState({'email': event.target.value}); }, hideMessage: function() { this.setState({'hideMsg': true}); }, displayMessage: function(msg, ok) { this.setState({'msg': msg, 'msgOk': ok, 'hideMsg': false}); }, render: function() { var cName = classNames('form-message', {'hidden': this.state.hideMsg, 'message-ok': this.state.msgOk}); return (
{this.state.msg}
Sign In
); } });