// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. var Utils = require('../utils/utils.jsx'); var Client = require('../utils/client.jsx'); var BrowserStore = require('../stores/browser_store.jsx'); export default class TeamSignupWelcomePage extends React.Component { constructor(props) { super(props); this.submitNext = this.submitNext.bind(this); this.handleDiffEmail = this.handleDiffEmail.bind(this); this.handleDiffSubmit = this.handleDiffSubmit.bind(this); this.handleKeyPress = this.handleKeyPress.bind(this); this.state = {useDiff: false}; document.addEventListener('keyup', this.handleKeyPress, false); } submitNext(e) { if (!BrowserStore.isLocalStorageSupported()) { this.setState({storageError: 'This service requires local storage to be enabled. Please enable it or exit private browsing.'}); return; } e.preventDefault(); this.props.state.wizard = 'team_display_name'; this.props.updateParent(this.props.state); } handleDiffEmail(e) { e.preventDefault(); this.setState({useDiff: true}); } handleDiffSubmit(e) { e.preventDefault(); var state = {useDiff: true, serverError: ''}; var email = ReactDOM.findDOMNode(this.refs.email).value.trim().toLowerCase(); if (!email || !Utils.isEmail(email)) { state.emailError = 'Please enter a valid email address'; this.setState(state); return; } else if (!BrowserStore.isLocalStorageSupported()) { state.emailError = 'This service requires local storage to be enabled. Please enable it or exit private browsing.'; this.setState(state); return; } state.emailError = ''; Client.signupTeam(email, function success(data) { if (data.follow_link) { window.location.href = data.follow_link; } else { this.props.state.wizard = 'finished'; this.props.updateParent(this.props.state); window.location.href = '/signup_team_confirm/?email=' + encodeURIComponent(email); } }.bind(this), function error(err) { this.setState({serverError: err.message}); }.bind(this) ); } handleKeyPress(event) { if (event.keyCode === 13) { this.submitNext(event); } } componentWillUnmount() { document.removeEventListener('keyup', this.handleKeyPress, false); } render() { Client.track('signup', 'signup_team_01_welcome'); var storageError = null; if (this.state.storageError) { storageError = ; } var emailError = null; var emailDivClass = 'form-group'; if (this.state.emailError) { emailError = ; emailDivClass += ' has-error'; } var serverError = null; if (this.state.serverError) { serverError = (
); } var differentEmailLinkClass = ''; var emailDivContainerClass = 'hidden'; if (this.state.useDiff) { differentEmailLinkClass = 'hidden'; emailDivContainerClass = ''; } return (

Welcome to:

{global.window.config.SiteName}

Let's set up your new team

Please confirm your email address:

{this.props.state.team.email}

Your account will administer the new team site.
You can add other administrators later.

{storageError}

{emailError}
{serverError}
Use a different email
); } } TeamSignupWelcomePage.defaultProps = { state: {} }; TeamSignupWelcomePage.propTypes = { updateParent: React.PropTypes.func.isRequired, state: React.PropTypes.object };