// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. // See License.txt for license information. var utils = require('../utils/utils.jsx'); var client = require('../utils/client.jsx'); module.exports = React.createClass({ displayName: 'TeamSignupPasswordPage', propTypes: { state: React.PropTypes.object, updateParent: React.PropTypes.func }, submitBack: function(e) { e.preventDefault(); this.props.state.wizard = 'username'; this.props.updateParent(this.props.state); }, submitNext: function(e) { e.preventDefault(); var password = this.refs.password.getDOMNode().value.trim(); if (!password || password.length < 5) { this.setState({passwordError: 'Please enter at least 5 characters'}); return; } this.setState({passwordError: null, serverError: null}); $('#finish-button').button('loading'); var teamSignup = JSON.parse(JSON.stringify(this.props.state)); teamSignup.user.password = password; teamSignup.user.allow_marketing = true; delete teamSignup.wizard; // var ctl = this; client.createTeamFromSignup(teamSignup, function success() { client.track('signup', 'signup_team_08_complete'); var props = this.props; $('#sign-up-button').button('reset'); props.state.wizard = 'finished'; props.updateParent(props.state, true); window.location.href = utils.getWindowLocationOrigin() + '/' + props.state.team.name + '/login?email=' + encodeURIComponent(teamSignup.team.email); // client.loginByEmail(teamSignup.team.domain, teamSignup.team.email, teamSignup.user.password, // function(data) { // TeamStore.setLastName(teamSignup.team.domain); // UserStore.setLastEmail(teamSignup.team.email); // UserStore.setCurrentUser(data); // window.location.href = '/channels/town-square'; // }.bind(ctl), // function(err) { // this.setState({nameError: err.message}); // }.bind(ctl) // ); }.bind(this), function error(err) { this.setState({serverError: err.message}); $('#sign-up-button').button('reset'); }.bind(this) ); }, getInitialState: function() { return {}; }, render: function() { client.track('signup', 'signup_team_07_password'); var passwordError = null; var passwordDivStyle = 'form-group'; if (this.state.passwordError) { passwordError =
; passwordDivStyle = ' has-error'; } var serverError = null; if (this.state.serverError) { serverError = ; } return (