// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
// See License.txt for license information.
var EmailItem = require('./team_signup_email_item.jsx');
var utils = require('../utils/utils.jsx');
var ConfigStore = require('../stores/config_store.jsx');
var client = require('../utils/client.jsx');
module.exports = React.createClass({
displayName: 'TeamSignupSendInivtesPage',
propTypes: {
state: React.PropTypes.object,
updateParent: React.PropTypes.func
},
submitBack: function(e) {
e.preventDefault();
if (config.AllowSignupDomainsWizard) {
this.props.state.wizard = 'allowed_domains';
} else {
this.props.state.wizard = 'team_url';
}
this.props.updateParent(this.props.state);
},
submitNext: function(e) {
e.preventDefault();
var valid = true;
if (this.state.emailEnabled) {
var emails = [];
for (var i = 0; i < this.props.state.invites.length; i++) {
if (!this.refs['email_' + i].validate(this.props.state.team.email)) {
valid = false;
} else {
emails.push(this.refs['email_' + i].getValue());
}
}
if (valid) {
this.props.state.invites = emails;
}
}
if (valid) {
this.props.state.wizard = 'username';
this.props.updateParent(this.props.state);
}
},
submitAddInvite: function(e) {
e.preventDefault();
this.props.state.wizard = 'send_invites';
if (!this.props.state.invites) {
this.props.state.invites = [];
}
this.props.state.invites.push('');
this.props.updateParent(this.props.state);
},
submitSkip: function(e) {
e.preventDefault();
this.props.state.wizard = 'username';
this.props.updateParent(this.props.state);
},
getInitialState: function() {
return {
emailEnabled: !ConfigStore.getSettingAsBoolean('ByPassEmail', false)
};
},
render: function() {
client.track('signup', 'signup_team_05_send_invites');
var content = null;
var bottomContent = null;
if (this.state.emailEnabled) {
var emails = [];
for (var i = 0; i < this.props.state.invites.length; i++) {
if (i === 0) {
emails.push(
{'if you prefer, you can invite ' + strings.Team + ' members later'}
and skip this step for now.