import { Button, Theme, withStyles, WithStyles } from '@material-ui/core'; import { ApolloClient } from 'apollo-client'; import { isArray } from 'lodash'; import * as qs from 'query-string'; import * as React from 'react'; import { withApollo, WithApolloClient } from 'react-apollo'; import { Field } from 'react-final-form'; import { Link, RouteComponentProps } from 'react-router-dom'; import google from '../../assets/google.svg'; import Form from '../../components/Form'; import Input from '../../components/form/TextField'; import { showMessage } from '../../components/Toast'; import { requestJSON } from '../../util/http'; import AccountPage from './AccountPage'; const styles = (theme: 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(); }; interface Props extends WithStyles, RouteComponentProps<{}>, WithApolloClient<{}> {} interface State { error?: string | string[]; } class SignIn extends React.Component { constructor(props: Props) { super(props); const { error } = qs.parse(this.props.location.search); this.state = { error, }; } public componentDidMount() { if (this.state.error) { const msg = isArray(this.state.error) ? this.state.error : [this.state.error]; showMessage(msg.join(' '), true); this.props.history.replace(`/signin`); } } public render() { const { classes, client } = this.props; return ( Forgot password? } >
{({ handleSubmit, submitting }) => ( )}
); } } export default withApollo(withStyles(styles)(SignIn));