From 989fb5c7dbba174f54f3ae69df788d6685fff46b Mon Sep 17 00:00:00 2001 From: jloup Date: Sat, 24 Feb 2018 17:06:57 +0100 Subject: Upgrade ReactJS. EC6 import modules. --- cmd/web/js/otp.jsx | 72 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 32 deletions(-) (limited to 'cmd/web/js/otp.jsx') diff --git a/cmd/web/js/otp.jsx b/cmd/web/js/otp.jsx index a0ee5cc..aecf032 100644 --- a/cmd/web/js/otp.jsx +++ b/cmd/web/js/otp.jsx @@ -1,9 +1,10 @@ -var Api = require('./api.js').Api; -var App = require('./app.js'); -var classNames = require('classnames'); +import Api from './api.js'; +import App from './app.js'; +import classNames from 'classnames'; +import React from 'react'; -var OtpQrCode = React.createClass({ - render: function() { +class OtpQrCode extends React.Component { + render = () => { return (
@@ -11,13 +12,15 @@ var OtpQrCode = React.createClass({
); } -}); +} -module.exports.OtpEnrollForm = React.createClass({ - getInitialState: function() { - return {'hideMsg': true, 'msg': '', 'msgOk': false, 'pass': ''}; - }, - handleSubmit: function(e) { +class OtpEnrollForm extends React.Component { + constructor(props) { + super(props); + this.state = {'hideMsg': true, 'msg': '', 'msgOk': false, 'pass': ''}; + } + + handleSubmit = (e) => { Api.Call('OTP_VALIDATE', {'pass': this.state.pass}, function(err, status, data) { if (err) { console.error(err, data); @@ -31,40 +34,45 @@ module.exports.OtpEnrollForm = React.createClass({ }.bind(this)); e.preventDefault(); - }, - handlePassChange: function(event) { + } + + handlePassChange = (event) => { this.setState({'pass': 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}); var qrCode = null; if (this.props.img) { - qrCode = ( -
+ qrCode = +
-
- ); - } +
; +} return ( -
-
+
+
{qrCode} -
-
- - -
{this.state.msg}
+
+ + + +
{this.state.msg}
); } -}); +} + +export default OtpEnrollForm; -- cgit v1.2.3