From c766a3aabba6fda6d9e7e13e39f8780226989fe6 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 10 Jul 2019 18:58:52 +0300 Subject: login wip --- vnext/src/ui/Login.js | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 vnext/src/ui/Login.js (limited to 'vnext/src/ui/Login.js') diff --git a/vnext/src/ui/Login.js b/vnext/src/ui/Login.js new file mode 100644 index 00000000..649fadd4 --- /dev/null +++ b/vnext/src/ui/Login.js @@ -0,0 +1,92 @@ +import React, { useState, useEffect } from 'react'; +import PropTypes from 'prop-types'; + +import ReactRouterPropTypes from 'react-router-prop-types'; +import { withRouter } from 'react-router-dom'; + +import { UserType } from './Types'; +import Icon from './Icon'; +import Button from './Button'; +import Input from './Input'; +import { useFormState } from 'react-use-form-state'; + +import { me, facebookLink, vkLink } from '../api'; + +import './Login.css'; + +function Login({ visitor, history, location, onAuth }) { + + useEffect(() => { + if (visitor.hash) { + const {retpath } = location.state; + console.log(retpath); + history.push(retpath || '/'); + } + }, [history, location.state, visitor]); + + const [formState, { text, password }] = useFormState(); + + let onSubmit = (event) => { + event.preventDefault(); + me(formState.values.username, formState.values.password) + .then(response => { + onAuth(response); + } + ).catch(ex => { + console.log(ex); + }); + }; + return ( +
+
+

Please, introduce yourself:

+
+ + Log in + + + + Log in + +
+

Already registered?

+
+
+
+ +
+
+
+ ); +} + +export default withRouter(Login); + +Login.propTypes = { + visitor: UserType, + history: ReactRouterPropTypes.history.isRequired, + location: ReactRouterPropTypes.location, + onAuth: PropTypes.func +}; + +const socialButtonsStyle = { + display: 'flex', + justifyContent: 'space-evenly', + padding: '4px' +}; + +const facebookButtonStyle = { + color: '#fff', + padding: '2px 14px', + background: '#3b5998' +}; + +const vkButtonStyle = { + color: '#fff', + padding: '2px 14px', + background: '#4c75a3' +}; -- cgit v1.2.3