import { ApolloClient, useApolloClient } from '@apollo/client'; import { Button } from '@material-ui/core'; import { makeStyles } from '@material-ui/core/styles'; import * as React from 'react'; import { useEffect } from 'react'; import { Field, FormRenderProps } from 'react-final-form'; import { Link, useHistory, useLocation } from 'react-router-dom'; import google from '../../assets/google.svg'; import Form from '../../components/Form'; import Input from '../../components/form/TextField'; import { showErrorMessage } from '../../components/Toast'; import { requestJSON } from '../../util/http'; import { asArray } from '../../util/util'; import AccountPage from './AccountPage'; const useStyles = makeStyles(theme => ({ submit: { width: '100%', marginTop: theme.spacing(4), }, google: { width: '100%', marginTop: theme.spacing(4), background: theme.palette.common.white, }, googleButton: { display: 'flex', alignItems: 'center', '& img': { marginRight: theme.spacing(1), height: 18, }, }, })); const logIn = (client: ApolloClient) => async ({ username, password, }: { username: string; password: string; }) => { await requestJSON('/auth/signin/local', 'post', { username, password, }); await client.reFetchObservableQueries(); }; const SignIn = () => { const { search } = useLocation(); const error = new URLSearchParams(search).get('error'); const history = useHistory(); const classes = useStyles(); const client = useApolloClient(); useEffect(() => { if (error) { const msg = asArray(error); showErrorMessage(msg.join(' ')); history.replace('/signing'); } }, [error, history]); return ( Forgot password? } >
( )} />
); }; export default SignIn;