text: /*
   *
   * ForgotPassword
   *
   */
  
  import React from 'react';
  import { connect } from 'react-redux';
  
  import { Row, Col } from 'reactstrap';
  import { Redirect, Link } from 'react-router-dom';
  
  import actions from '../../actions';
  
  import Input from '../../components/Common/Input';
  import Button from '../../components/Common/Button';
  
  class ForgotPassword extends React.PureComponent {
    render() {
      const {
        authenticated,
        forgotFormData,
        formErrors,
        forgotPasswordChange,
        forgotPassowrd
      } = this.props;
  
      if (authenticated) return <Redirect to='/dashboard' />;
  
      const handleSubmit = event => {
        event.preventDefault();
        forgotPassowrd();
      };
  
      return (
        <div className='forgot-password-form'>
          <h2>Forgot Password</h2>
          <hr />
          <form onSubmit={handleSubmit}>
            <Row>
              <Col xs='12' md='6'>
                <Input
                  type={'text'}
                  error={formErrors['email']}
                  label={'Email Address'}
                  name={'email'}
                  placeholder={'Please Enter Your Email'}
                  value={forgotFormData.email}
                  onInputChange={(name, value) => {
                    forgotPasswordChange(name, value);
                  }}
                />
              </Col>
            </Row>
            <hr />
            <div className='d-flex flex-column flex-md-row align-items-md-center justify-content-between'>
              <Button
                type='submit'
                variant='primary'
                text='Send Email'
                className='mb-3 mb-md-0'
              />
              <Link className='redirect-link' to={'/login'}>
                Back to login
              </Link>
            </div>
          </form>
        </div>
      );
    }
  }
  
  const mapStateToProps = state => {
    return {
      authenticated: state.authentication.authenticated,
      forgotFormData: state.forgotPassword.forgotFormData,
      formErrors: state.forgotPassword.formErrors
    };
  };
  
  export default connect(mapStateToProps, actions)(ForgotPassword);
  