From 7a9e5112eaaea58d55f181d3e5296e4ff839921c Mon Sep 17 00:00:00 2001 From: jloup Date: Wed, 14 Feb 2018 14:19:09 +0100 Subject: initial commit --- cmd/web/js/signin.jsx | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 cmd/web/js/signin.jsx (limited to 'cmd/web/js/signin.jsx') diff --git a/cmd/web/js/signin.jsx b/cmd/web/js/signin.jsx new file mode 100644 index 0000000..443a461 --- /dev/null +++ b/cmd/web/js/signin.jsx @@ -0,0 +1,52 @@ +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) { + Api.Call('SIGNIN', {'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('OK', 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 ( +
+
+
+ + + +
{this.state.msg}
+
+ Sign up +
+
+ ); + } +}); + -- cgit v1.2.3