diff options
Diffstat (limited to 'cmd/web/js/signin.jsx')
-rw-r--r-- | cmd/web/js/signin.jsx | 66 |
1 files changed, 38 insertions, 28 deletions
diff --git a/cmd/web/js/signin.jsx b/cmd/web/js/signin.jsx index a2cfd1b..bff497e 100644 --- a/cmd/web/js/signin.jsx +++ b/cmd/web/js/signin.jsx | |||
@@ -1,12 +1,15 @@ | |||
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.SigninForm = React.createClass({ | 5 | |
6 | getInitialState: function() { | 6 | class SigninForm 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 | } | ||
11 | |||
12 | handleSubmit = (e) => { | ||
10 | Api.Call('SIGNIN', {'password': this.state.password, 'email': this.state.email}, function(err, status, data) { | 13 | Api.Call('SIGNIN', {'password': this.state.password, 'email': this.state.email}, function(err, status, data) { |
11 | if (err) { | 14 | if (err) { |
12 | console.error(err, data); | 15 | console.error(err, data); |
@@ -19,34 +22,41 @@ module.exports.SigninForm = React.createClass({ | |||
19 | 22 | ||
20 | }.bind(this)); | 23 | }.bind(this)); |
21 | e.preventDefault(); | 24 | e.preventDefault(); |
22 | }, | 25 | } |
23 | handlePasswordChange: function(event) { | 26 | |
27 | handlePasswordChange = (event) => { | ||
24 | this.setState({'password': event.target.value}); | 28 | this.setState({'password': event.target.value}); |
25 | }, | 29 | } |
26 | handleEmailChange: function(event) { | 30 | |
31 | handleEmailChange = (event) => { | ||
27 | this.setState({'email': event.target.value}); | 32 | this.setState({'email': event.target.value}); |
28 | }, | 33 | } |
29 | hideMessage: function() { | 34 | |
35 | hideMessage = () => { | ||
30 | this.setState({'hideMsg': true}); | 36 | this.setState({'hideMsg': true}); |
31 | }, | 37 | } |
32 | displayMessage: function(msg, ok) { | 38 | |
39 | displayMessage = (msg, ok) => { | ||
33 | this.setState({'msg': msg, 'msgOk': ok, 'hideMsg': false}); | 40 | this.setState({'msg': msg, 'msgOk': ok, 'hideMsg': false}); |
34 | }, | 41 | } |
35 | render: function() { | 42 | |
43 | render = () => { | ||
36 | var cName = classNames('form-message', {'hidden': this.state.hideMsg, 'message-ok': this.state.msgOk}); | 44 | var cName = classNames('form-message', {'hidden': this.state.hideMsg, 'message-ok': this.state.msgOk}); |
37 | return ( | 45 | return ( |
38 | <div className='row sign-in'> | 46 | <div className="row sign-in"> |
39 | <div className='offset-4 col-4 col-xs-offset-1 col-xs-10 text-center'> | 47 | <div className="offset-4 col-4 col-xs-offset-1 col-xs-10 text-center"> |
40 | <form role='form' onSubmit={this.handleSubmit}> | 48 | <form role="form" onSubmit={this.handleSubmit}> |
41 | <input className='form-control' type='email' placeholder='email' onChange={this.handleEmailChange} /> | 49 | <input className="form-control" type="email" placeholder="email" onChange={this.handleEmailChange} /> |
42 | <input className='form-control' type='password' placeholder='password' onChange={this.handlePasswordChange} /> | 50 | <input className="form-control" type="password" placeholder="password" onChange={this.handlePasswordChange} /> |
43 | <input className='form-control submit' type='submit' value='Sign In' /> | 51 | <input className="form-control submit" type="submit" value="Sign In" /> |
44 | <div className={cName} ref='message'>{this.state.msg}</div> | 52 | <div className={cName}>{this.state.msg}</div> |
45 | </form> | 53 | </form> |
46 | <a href='#' onClick={App.onInternNavigation.bind(this, '/signup')}><u>Sign up</u></a> | 54 | <a href="#" onClick={App.onInternNavigation.bind(this, '/signup')}><u>Sign up</u></a> |
47 | </div> | 55 | </div> |
48 | </div> | 56 | </div> |
49 | ); | 57 | ); |
50 | } | 58 | } |
51 | }); | 59 | } |
60 | |||
61 | export default SigninForm; | ||
52 | 62 | ||