import React, { useEffect } from 'react'; import { useLocation, useHistory } from 'react-router-dom'; 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'; /** * @typedef {Object} LoginProps * @property {import('../api').SecureUser} visitor * @property {any} onAuth */ /** * Login page * @param {LoginProps} props */ function Login({ visitor, onAuth }) { const location = useLocation(); const history = useHistory(); useEffect(() => { if (visitor.hash) { const {retpath } = location.state; console.log(retpath); history.push(retpath || '/'); } }, [history, location.state, visitor]); const [formState, { text, password }] = useFormState(); /** * @param {React.SyntheticEvent} event */ 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 Login; 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' };