From 0907418ce2c6ca498b02e8e514e4945d79750467 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 5 Mar 2021 19:10:55 +0100 Subject: adding login view --- .../frontend/app/views/auth/auth.login.js | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 animism-align/frontend/app/views/auth/auth.login.js (limited to 'animism-align/frontend/app/views/auth/auth.login.js') diff --git a/animism-align/frontend/app/views/auth/auth.login.js b/animism-align/frontend/app/views/auth/auth.login.js new file mode 100644 index 0000000..9ba4c0b --- /dev/null +++ b/animism-align/frontend/app/views/auth/auth.login.js @@ -0,0 +1,76 @@ +import React, { Component } from 'react' + +import './auth.css' + +import actions from 'app/actions' +import { TextInput, SubmitButton } from 'app/common' + +export default class AuthLogin extends Component { + state = { + data: { + username: "", + password: "", + }, + error: null, + } + + constructor(props) { + super(props) + this.handleChange = this.handleChange.bind(this) + this.handleSubmit = this.handleSubmit.bind(this) + } + + handleChange(e) { + e && e.preventDefault() + console.log(e.target.name, e.target.value) + this.setState({ + data: { + ...this.state.data, + [e.target.name]: e.target.value + } + }) + } + + handleSubmit(e) { + e && e.preventDefault() + this.setState({ error: null }) + actions.auth.login(this.state) + .then(res => { + console.log(res) + if (res.error) { + this.props.onAuthenticate() + } else { + this.setState({ error }) + } + }) + } + + render() { + return ( +
+
+ Welcome to the Animism Editor +
+ + + + + ) + } +} \ No newline at end of file -- cgit v1.2.3-70-g09d2