import { useMutation } from '@apollo/client' import React, { ChangeEvent, FormEvent, useState } from 'react' import { LOGIN } from '../../apollo' import { MutationLoginArgs, ServerAnswer } from '../../apollo/typeDefs.gen' import styles from './main.module.css' import meme from './meme.png' import { Link } from 'react-router-dom' interface ILoginMutation { login: ServerAnswer } const Login: React.FC = () => { const [email, setEmail] = useState('') const [doLogin, { error, data, loading }] = useMutation< ILoginMutation, MutationLoginArgs >(LOGIN) const handleFormSubmit = async (e: FormEvent) => { e.preventDefault() try { await doLogin({ variables: { email } }) } catch (err) {} } const handleInputChange = (e: ChangeEvent) => { setEmail(e.currentTarget.value) } return (
You can't forget password if you don't have it
{data?.login.success ? (

You will get login link{' '}
in your mailbox

) : ( <>

Log In / Register

{loading ? ( 'Loading...' ) : ( )} {error &&

{error.message}

} )}
) } export default Login