From f578bb1e48ec4d97bca92c7faf0dd8ed5aeceb39 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Tue, 1 Sep 2015 17:06:31 -0700 Subject: MM-2065 style refactoring --- web/react/components/find_team.jsx | 64 ++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 26 deletions(-) (limited to 'web/react/components/find_team.jsx') diff --git a/web/react/components/find_team.jsx b/web/react/components/find_team.jsx index d896a1f12..b70c98d47 100644 --- a/web/react/components/find_team.jsx +++ b/web/react/components/find_team.jsx @@ -1,53 +1,57 @@ // 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({ - handleSubmit: function(e) { +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 = this.refs.email.getDOMNode().value.trim().toLowerCase(); if (!email || !utils.isEmail(email)) { - state.email_error = "Please enter a valid email address"; + state.email_error = 'Please enter a valid email address'; this.setState(state); return; } - else { - state.email_error = ""; - } + + state.email_error = ''; client.findTeamsSendEmail(email, - function(data) { + function success() { state.sent = true; this.setState(state); }.bind(this), - function(err) { + function fail(err) { state.email_error = err.message; this.setState(state); }.bind(this) ); - }, - getInitialState: function() { - return { }; - }, - render: function() { + } - var email_error = this.state.email_error ? : null; + render() { + var emailError = null; + var emailErrorClass = 'form-group'; - var divStyle = { - "marginTop": "50px", + 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."}

+

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

+

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

); } @@ -56,17 +60,25 @@ module.exports = React.createClass({

Find Your Team

-

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

-
+

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

+
-
- - { email_error } +
+ + {emailError}
- +
); } -}); +} -- cgit v1.2.3-1-g7c22