diff --git a/browser/app/js/browser/Login.js b/browser/app/js/browser/Login.js index f8ceceb64..d71aff162 100644 --- a/browser/app/js/browser/Login.js +++ b/browser/app/js/browser/Login.js @@ -25,14 +25,35 @@ import web from "../web" import { Redirect } from "react-router-dom" export class Login extends React.Component { + constructor(props) { + super(props) + this.state = { + accessKey: "", + secretKey: "" + } + } + + // Handle field changes + accessKeyChange(e) { + this.setState({ + accessKey: e.target.value + }) + } + + secretKeyChange(e) { + this.setState({ + secretKey: e.target.value + }) + } + handleSubmit(event) { event.preventDefault() const { showAlert, history } = this.props let message = "" - if (!document.getElementById("accessKey").value) { + if (this.state.accessKey === "") { message = "Access Key cannot be empty" } - if (!document.getElementById("secretKey").value) { + if (this.state.secretKey === "") { message = "Secret Key cannot be empty" } if (message) { @@ -41,8 +62,8 @@ export class Login extends React.Component { } web .Login({ - username: document.getElementById("accessKey").value, - password: document.getElementById("secretKey").value + username: this.state.accessKey, + password: this.state.secretKey }) .then(res => { history.push("/") @@ -77,6 +98,8 @@ export class Login extends React.Component {