blob: 219f14eefa536986e5e8326df031d832c773698d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
const Utils = require('../utils/utils.jsx');
export default class TeamSignupEmailItem extends React.Component {
constructor(props) {
super(props);
this.getValue = this.getValue.bind(this);
this.validate = this.validate.bind(this);
this.state = {};
}
getValue() {
return React.findDOMNode(this.refs.email).value.trim();
}
validate(teamEmail) {
const email = React.findDOMNode(this.refs.email).value.trim().toLowerCase();
if (!email) {
return true;
}
if (!Utils.isEmail(email)) {
this.setState({emailError: 'Please enter a valid email address'});
return false;
} else if (email === teamEmail) {
this.setState({emailError: 'Please use a different email than the one used at signup'});
return false;
}
this.setState({emailError: ''});
return true;
}
render() {
let emailError = null;
let 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>
);
}
}
TeamSignupEmailItem.propTypes = {
focus: React.PropTypes.bool,
email: React.PropTypes.string
};
|