import React from 'react'; import { connect } from 'react-redux'; import { Link } from 'react-router-dom'; import { Button, Alert, Input } from 'antd'; import { authActions } from 'modules/auth'; import { AppState } from 'store/reducers'; import './SignIn.less'; interface OwnProps { matchUrl: string; } interface StateProps { isAuthingUser: AppState['auth']['isAuthingUser']; authUserError: AppState['auth']['authUserError']; } interface DispatchProps { authUser: typeof authActions['authUser']; } type Props = OwnProps & StateProps & DispatchProps; const STATE = { password: '', email: '', isAttemptedAuth: false, }; type State = typeof STATE; class SignIn extends React.Component { state: State = { ...STATE }; render() { const { authUserError, isAuthingUser, matchUrl } = this.props; const { email, password, isAttemptedAuth } = this.state; return (
this.setState({ email: e.currentTarget.value })} size="large" autoComplete="email" required={true} /> this.setState({ password: e.currentTarget.value })} size="large" autoComplete="current-password" required={true} />
Forgot your password?{' '} Recover your account.
{isAttemptedAuth && authUserError && ( )}
); } private handleLogin = (ev: React.FormEvent) => { ev.preventDefault(); const { email, password } = this.state; this.setState({ isAttemptedAuth: true }); this.props.authUser(email, password); }; } export default connect( state => ({ isAuthingUser: state.auth.isAuthingUser, authUserError: state.auth.authUserError, }), { authUser: authActions.authUser, }, )(SignIn);