import React, { Component, PropTypes } from 'react'; import { connect } from 'react-redux'; import { push } from 'react-router-redux'; import { noop } from 'lodash'; import { clearForgotPasswordErrors, forgotPasswordAction, } from 'redux/nodes/components/ForgotPasswordPage/actions'; import debounce from 'utilities/debounce'; import ForgotPasswordForm from 'components/forms/ForgotPasswordForm'; import Icon from 'components/icons/Icon'; import StackedWhiteBoxes from 'components/StackedWhiteBoxes'; export class ForgotPasswordPage extends Component { static propTypes = { dispatch: PropTypes.func, email: PropTypes.string, errors: PropTypes.shape({ base: PropTypes.string, }), }; static defaultProps = { dispatch: noop, }; componentWillUnmount () { return this.clearErrors(); } handleLeave = (location) => { const { dispatch } = this.props; return dispatch(push(location)); } handleSubmit = debounce((formData) => { const { dispatch } = this.props; return dispatch(forgotPasswordAction(formData)) .catch(() => false); }) clearErrors = () => { const { dispatch } = this.props; return dispatch(clearForgotPasswordErrors); } renderContent = () => { const { clearErrors, handleSubmit } = this; const { email, errors } = this.props; const baseClass = 'forgot-password'; if (email) { return (
An email was sent to {email}. Click the link on the email to proceed with the password reset process.