From 989fb5c7dbba174f54f3ae69df788d6685fff46b Mon Sep 17 00:00:00 2001
From: jloup <jeanloup.jamet@gmail.com>
Date: Sat, 24 Feb 2018 17:06:57 +0100
Subject: Upgrade ReactJS. EC6 import modules.

---
 cmd/web/js/signin.jsx | 66 +++++++++++++++++++++++++++++----------------------
 1 file changed, 38 insertions(+), 28 deletions(-)

(limited to 'cmd/web/js/signin.jsx')

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 @@
-var Api        = require('./api.js').Api;
-var App        = require('./app.js');
-var classNames = require('classnames');
-
-module.exports.SigninForm = React.createClass({
-  getInitialState: function() {
-    return {'hideMsg': true, 'msg': '', 'msgOk': false, 'password': '', 'email': ''};
-  },
-  handleSubmit: function(e) {
+import Api from './api.js';
+import App from './app.js';
+import classNames from 'classnames';
+import React from 'react';
+
+class SigninForm extends React.Component {
+  constructor(props) {
+    super(props);
+    this.state = {'hideMsg': true, 'msg': '', 'msgOk': false, 'password': '', 'email': ''};
+  }
+
+  handleSubmit = (e) => {
     Api.Call('SIGNIN', {'password': this.state.password, 'email': this.state.email}, function(err, status, data) {
       if (err) {
         console.error(err, data);
@@ -19,34 +22,41 @@ module.exports.SigninForm = React.createClass({
 
     }.bind(this));
     e.preventDefault();
-  },
-  handlePasswordChange: function(event) {
+  }
+
+  handlePasswordChange = (event) => {
     this.setState({'password': event.target.value});
-  },
-  handleEmailChange: function(event) {
+  }
+
+  handleEmailChange = (event) => {
     this.setState({'email': event.target.value});
-  },
-  hideMessage: function() {
+  }
+
+  hideMessage = () => {
     this.setState({'hideMsg': true});
-  },
-  displayMessage: function(msg, ok) {
+  }
+
+  displayMessage = (msg, ok) => {
     this.setState({'msg': msg, 'msgOk': ok, 'hideMsg': false});
-  },
-  render: function() {
+  }
+
+  render = () => {
     var cName = classNames('form-message', {'hidden': this.state.hideMsg, 'message-ok': this.state.msgOk});
     return (
-        <div className='row sign-in'>
-          <div className='offset-4 col-4 col-xs-offset-1 col-xs-10 text-center'>
-            <form role='form' onSubmit={this.handleSubmit}>
-              <input className='form-control' type='email' placeholder='email' onChange={this.handleEmailChange} />
-              <input className='form-control' type='password' placeholder='password' onChange={this.handlePasswordChange} />
-              <input className='form-control submit' type='submit' value='Sign In' />
-              <div className={cName} ref='message'>{this.state.msg}</div>
+        <div className="row sign-in">
+          <div className="offset-4 col-4 col-xs-offset-1 col-xs-10 text-center">
+            <form role="form" onSubmit={this.handleSubmit}>
+              <input className="form-control" type="email" placeholder="email" onChange={this.handleEmailChange} />
+              <input className="form-control" type="password" placeholder="password" onChange={this.handlePasswordChange} />
+              <input className="form-control submit" type="submit" value="Sign In" />
+              <div className={cName}>{this.state.msg}</div>
             </form>
-            <a href='#' onClick={App.onInternNavigation.bind(this, '/signup')}><u>Sign up</u></a>
+            <a href="#" onClick={App.onInternNavigation.bind(this, '/signup')}><u>Sign up</u></a>
           </div>
         </div>
        );
   }
-});
+}
+
+export default SigninForm;
 
-- 
cgit v1.2.3

