summaryrefslogtreecommitdiffstats
path: root/web/react/components/team_signup_email_item.jsx
diff options
context:
space:
mode:
authorReed Garmsen <rgarmsen2295@gmail.com>2015-08-18 09:15:16 -0700
committerReed Garmsen <rgarmsen2295@gmail.com>2015-08-18 09:15:16 -0700
commit84c82e8d7a1a7e4ec8808b86ff5bea78138d1886 (patch)
treef5e06cefc88cf5a2167d345d3a819f5d8f71e440 /web/react/components/team_signup_email_item.jsx
parent5dbfa999494e7569e064cb1bc9f2dd5ab414eb9e (diff)
downloadchat-84c82e8d7a1a7e4ec8808b86ff5bea78138d1886.tar.gz
chat-84c82e8d7a1a7e4ec8808b86ff5bea78138d1886.tar.bz2
chat-84c82e8d7a1a7e4ec8808b86ff5bea78138d1886.zip
Renamed new component files for easier identification
Diffstat (limited to 'web/react/components/team_signup_email_item.jsx')
-rw-r--r--web/react/components/team_signup_email_item.jsx53
1 files changed, 53 insertions, 0 deletions
diff --git a/web/react/components/team_signup_email_item.jsx b/web/react/components/team_signup_email_item.jsx
new file mode 100644
index 000000000..11cd17e74
--- /dev/null
+++ b/web/react/components/team_signup_email_item.jsx
@@ -0,0 +1,53 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+var utils = require('../utils/utils.jsx');
+
+module.exports = React.createClass({
+ displayName: 'TeamSignupEmailItem',
+ propTypes: {
+ focus: React.PropTypes.bool,
+ email: React.PropTypes.string
+ },
+ getInitialState: function() {
+ return {};
+ },
+ getValue: function() {
+ return this.refs.email.getDOMNode().value.trim();
+ },
+ validate: function(teamEmail) {
+ var email = this.refs.email.getDOMNode().value.trim().toLowerCase();
+
+ if (!email) {
+ return true;
+ }
+
+ if (!utils.isEmail(email)) {
+ this.state.emailError = 'Please enter a valid email address';
+ this.setState(this.state);
+ return false;
+ } else if (email === teamEmail) {
+ this.state.emailError = 'Please use a different email than the one used at signup';
+ this.setState(this.state);
+ return false;
+ }
+ this.state.emailError = '';
+ this.setState(this.state);
+ return true;
+ },
+ render: function() {
+ var emailError = null;
+ var emailDivClass = 'form-group';
+ if (this.state.emailError) {
+ emailError = <label className='control-label'>{this.state.emailError}</label>;
+ emailDivClass += ' has-error';
+ }
+
+ return (
+ <div className={emailDivClass}>
+ <input autoFocus={this.props.focus} type='email' ref='email' className='form-control' placeholder='Email Address' defaultValue={this.props.email} maxLength='128' />
+ {emailError}
+ </div>
+ );
+ }
+});