diff options
Diffstat (limited to 'cmd/web/js/signup.jsx')
-rw-r--r-- | cmd/web/js/signup.jsx | 100 |
1 files changed, 56 insertions, 44 deletions
diff --git a/cmd/web/js/signup.jsx b/cmd/web/js/signup.jsx index 404a828..affa18e 100644 --- a/cmd/web/js/signup.jsx +++ b/cmd/web/js/signup.jsx | |||
@@ -1,56 +1,68 @@ | |||
1 | var Api = require('./api.js').Api; | 1 | import Api from './api.js'; |
2 | var App = require('./app.js'); | 2 | import App from './app.js'; |
3 | var classNames = require('classnames'); | 3 | import classNames from 'classnames'; |
4 | 4 | import React from 'react'; | |
5 | module.exports.SignupForm = React.createClass({ | 5 | |
6 | getInitialState: function() { | 6 | class SignupForm extends React.Component { |
7 | return {'hideMsg': true, 'msg': '', 'msgOk': false, 'password': '', 'email': ''}; | 7 | constructor(props) { |
8 | }, | 8 | super(props); |
9 | handleSubmit: function(e) { | 9 | this.state = {'hideMsg': true, 'msg': '', 'msgOk': false, 'password': '', 'email': ''}; |
10 | Api.Call('SIGNUP', | 10 | } |
11 | { | 11 | |
12 | 'password': this.state.password, | 12 | handleSubmit = (e) => { |
13 | 'email': this.state.email | 13 | Api.Call( |
14 | }, | 14 | 'SIGNUP', |
15 | function(err, status, data) { | 15 | { |
16 | if (err) { | 16 | 'password': this.state.password, |
17 | console.error(err, data); | 17 | 'email': this.state.email |
18 | this.displayMessage(App.errorCodeToMessage(err.code), false); | 18 | }, |
19 | return; | 19 | function(err, status, data) { |
20 | } | 20 | if (err) { |
21 | 21 | console.error(err, data); | |
22 | this.displayMessage('Thank You. Your account is being confirmed. Check your mailbox soon', true); | 22 | this.displayMessage(App.errorCodeToMessage(err.code), false); |
23 | this.props.onSuccess(data.token); | 23 | return; |
24 | 24 | } | |
25 | }.bind(this)); | 25 | |
26 | this.displayMessage('Thank You. Your account is being confirmed. Check your mailbox soon', true); | ||
27 | this.props.onSuccess(data.token); | ||
28 | |||
29 | }.bind(this) | ||
30 | ); | ||
26 | e.preventDefault(); | 31 | e.preventDefault(); |
27 | }, | 32 | } |
28 | handlePasswordChange: function(event) { | 33 | |
34 | handlePasswordChange = (event) => { | ||
29 | this.setState({'password': event.target.value}); | 35 | this.setState({'password': event.target.value}); |
30 | }, | 36 | } |
31 | handleEmailChange: function(event) { | 37 | |
38 | handleEmailChange = (event) => { | ||
32 | this.setState({'email': event.target.value}); | 39 | this.setState({'email': event.target.value}); |
33 | }, | 40 | } |
34 | hideMessage: function() { | 41 | |
42 | hideMessage = () => { | ||
35 | this.setState({'hideMsg': true}); | 43 | this.setState({'hideMsg': true}); |
36 | }, | 44 | } |
37 | displayMessage: function(msg, ok) { | 45 | |
46 | displayMessage = (msg, ok) => { | ||
38 | this.setState({'msg': msg, 'msgOk': ok, 'hideMsg': false}); | 47 | this.setState({'msg': msg, 'msgOk': ok, 'hideMsg': false}); |
39 | }, | 48 | } |
40 | render: function() { | 49 | |
50 | render = () => { | ||
41 | var cName = classNames('form-message', {'hidden': this.state.hideMsg, 'message-ok': this.state.msgOk}); | 51 | var cName = classNames('form-message', {'hidden': this.state.hideMsg, 'message-ok': this.state.msgOk}); |
42 | return ( | 52 | return ( |
43 | <div className='row sign-in'> | 53 | <div className="row sign-in"> |
44 | <div className='offset-4 col-4 col-xs-offset-1 col-xs-10 text-center'> | 54 | <div className="offset-4 col-4 col-xs-offset-1 col-xs-10 text-center"> |
45 | <form role='form' onSubmit={this.handleSubmit}> | 55 | <form role="form" onSubmit={this.handleSubmit}> |
46 | <input className='form-control' type='email' placeholder='email' onChange={this.handleEmailChange} /> | 56 | <input className="form-control" type="email" placeholder="email" onChange={this.handleEmailChange} /> |
47 | <input className='form-control' type='password' placeholder='password' onChange={this.handlePasswordChange} /> | 57 | <input className="form-control" type="password" placeholder="password" onChange={this.handlePasswordChange} /> |
48 | <input className='form-control submit' type='submit' value='Sign Up' /> | 58 | <input className="form-control submit" type="submit" value="Sign Up" /> |
49 | <div className={cName} ref='message'>{this.state.msg}</div> | 59 | <div className={cName}>{this.state.msg}</div> |
50 | <a href='#' onClick={App.onInternNavigation.bind(this, '/signin')}><u>Sign In</u></a> | 60 | <a href="#" onClick={App.onInternNavigation.bind(this, '/signin')}><u>Sign In</u></a> |
51 | </form> | 61 | </form> |
52 | </div> | 62 | </div> |
53 | </div> | 63 | </div> |
54 | ); | 64 | ); |
55 | } | 65 | } |
56 | }); | 66 | } |
67 | |||
68 | export default SignupForm; | ||