import { useEffect } from 'react'; import { useLocation, useNavigate } from 'react-router-dom'; import Icon from './Icon'; import Button from './Button'; import { useForm } from 'react-hook-form'; import { me, facebookLink, vkLink, appleLink } from '../api'; import { useVisitor } from './VisitorContext'; /** * @typedef {object} LoginProps * @property {Function} onAuth */ /** * Login page * * @param {LoginProps} props */ function Login({ onAuth }) { const location = useLocation(); const navigate = useNavigate(); const [visitor] = useVisitor(); useEffect(() => { if (visitor.hash) { const {retpath } = location.state || '/'; console.log(retpath); navigate(retpath); } }, [navigate, location.state, visitor]); const { register, handleSubmit } = useForm(); /** @type { import('react-hook-form').SubmitHandler } */ let onSubmit = (values) => { me(values.username, 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' };