From 7a9e5112eaaea58d55f181d3e5296e4ff839921c Mon Sep 17 00:00:00 2001
From: jloup <jean-loup.jamet@trainline.com>
Date: Wed, 14 Feb 2018 14:19:09 +0100
Subject: initial commit

---
 cmd/web/js/signup.jsx | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 cmd/web/js/signup.jsx

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

diff --git a/cmd/web/js/signup.jsx b/cmd/web/js/signup.jsx
new file mode 100644
index 0000000..149125a
--- /dev/null
+++ b/cmd/web/js/signup.jsx
@@ -0,0 +1,56 @@
+var Api                = require('./api.js').Api;
+var App                = require('./app.js');
+var classNames         = require('classnames');
+
+module.exports.SignupForm = React.createClass({
+  getInitialState: function() {
+    return {'hideMsg': true, 'msg': '', 'msgOk': false, 'password': '', 'email': ''};
+  },
+  handleSubmit: function(e) {
+    Api.Call('SIGNUP',
+             {
+            'password': this.state.password,
+            'email': this.state.email
+          },
+      function(err, status, data) {
+        if (err) {
+          console.error(err, data);
+          this.displayMessage(App.errorCodeToMessage(err.code), false);
+          return;
+        }
+
+        this.displayMessage('Thank You. Your account is being confirmed. Check your mailbox soon', true);
+        this.props.onSuccess(data.token);
+
+      }.bind(this));
+    e.preventDefault();
+  },
+  handlePasswordChange: function(event) {
+    this.setState({'password': event.target.value});
+  },
+  handleEmailChange: function(event) {
+    this.setState({'email': event.target.value});
+  },
+  hideMessage: function() {
+    this.setState({'hideMsg': true});
+  },
+  displayMessage: function(msg, ok) {
+    this.setState({'msg': msg, 'msgOk': ok, 'hideMsg': false});
+  },
+  render: function() {
+    var cName = classNames('form-message', {'hidden': this.state.hideMsg, 'message-ok': this.state.msgOk});
+    return (
+        <div className='row justify-content-center sign-in'>
+          <div className='col-lg-offset-4 col-lg-4 col-md-offset-4 col-md-4 col-sm-offset-4 col-sm-4 col-xs-offset-1 col-xs-10'>
+            <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 Up' />
+              <div className={cName} ref='message'>{this.state.msg}</div>
+              <a href='#' onClick={App.onInternNavigation.bind(this, '/signin')}><u>Sign In</u></a>
+            </form>
+          </div>
+        </div>
+       );
+  }
+});
-- 
cgit v1.2.3

