// 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'); import {strings} from '../utils/config.js'; export default class FindTeam extends React.Component { constructor(props) { super(props); this.state = {}; this.handleSubmit = this.handleSubmit.bind(this); } handleSubmit(e) { e.preventDefault(); var state = { }; var email = React.findDOMNode(this.refs.email).value.trim().toLowerCase(); if (!email || !utils.isEmail(email)) { state.email_error = 'Please enter a valid email address'; this.setState(state); return; } state.email_error = ''; client.findTeamsSendEmail(email, function success() { state.sent = true; this.setState(state); }.bind(this), function fail(err) { state.email_error = err.message; this.setState(state); }.bind(this) ); } render() { var emailError = null; var emailErrorClass = 'form-group'; if (this.state.email_error) { emailError = ; emailErrorClass = 'form-group has-error'; } if (this.state.sent) { return (

{'Find Your ' + utils.toTitleCase(strings.Team)}

{'An email was sent with links to any ' + strings.TeamPlural + ' to which you are a member.'}

); } return (

Find Your Team

{'Get an email with links to any ' + strings.TeamPlural + ' to which you are a member.'}

{emailError}
); } }