2016-09-16 13:55:46 +00:00
|
|
|
|
import React, { Component, PropTypes } from 'react';
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
import { noop } from 'lodash';
|
2016-09-14 20:31:54 +00:00
|
|
|
|
import componentStyles from './styles';
|
2016-09-16 13:55:46 +00:00
|
|
|
|
import {
|
|
|
|
|
clearForgotPasswordErrors,
|
|
|
|
|
forgotPasswordAction,
|
|
|
|
|
} from '../../redux/nodes/components/ForgotPasswordPage/actions';
|
2016-09-19 18:41:47 +00:00
|
|
|
|
import debounce from '../../utilities/debounce';
|
2016-09-14 20:31:54 +00:00
|
|
|
|
import ForgotPasswordForm from '../../components/forms/ForgotPasswordForm';
|
2016-09-16 13:55:46 +00:00
|
|
|
|
import Icon from '../../components/icons/Icon';
|
2016-09-16 21:19:37 +00:00
|
|
|
|
import StackedWhiteBoxes from '../../components/StackedWhiteBoxes';
|
2016-09-16 13:55:46 +00:00
|
|
|
|
|
|
|
|
|
export class ForgotPasswordPage extends Component {
|
|
|
|
|
static propTypes = {
|
|
|
|
|
dispatch: PropTypes.func,
|
|
|
|
|
email: PropTypes.string,
|
|
|
|
|
error: PropTypes.string,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static defaultProps = {
|
|
|
|
|
dispatch: noop,
|
|
|
|
|
};
|
2016-09-14 20:31:54 +00:00
|
|
|
|
|
2016-09-19 18:41:47 +00:00
|
|
|
|
onSubmit = debounce((formData) => {
|
2016-09-16 13:55:46 +00:00
|
|
|
|
const { dispatch } = this.props;
|
|
|
|
|
|
|
|
|
|
return dispatch(forgotPasswordAction(formData));
|
2016-09-19 18:41:47 +00:00
|
|
|
|
})
|
2016-09-16 13:55:46 +00:00
|
|
|
|
|
|
|
|
|
clearErrors = () => {
|
|
|
|
|
const { dispatch } = this.props;
|
|
|
|
|
|
|
|
|
|
return dispatch(clearForgotPasswordErrors);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderContent = () => {
|
|
|
|
|
const { clearErrors } = this;
|
|
|
|
|
const { email, error } = this.props;
|
|
|
|
|
const {
|
|
|
|
|
emailSentButtonWrapperStyles,
|
|
|
|
|
emailSentIconStyles,
|
|
|
|
|
emailSentTextStyles,
|
|
|
|
|
emailSentTextWrapperStyles,
|
|
|
|
|
emailTextStyles,
|
|
|
|
|
} = componentStyles;
|
|
|
|
|
|
|
|
|
|
if (email) {
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<div style={emailSentTextWrapperStyles}>
|
|
|
|
|
<p style={emailSentTextStyles}>
|
|
|
|
|
An email was sent to
|
|
|
|
|
<span style={emailTextStyles}> {email}</span>.
|
|
|
|
|
Click the link on the email to proceed with the password reset process.
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div style={emailSentButtonWrapperStyles}>
|
|
|
|
|
<Icon name="check" style={emailSentIconStyles} />
|
|
|
|
|
EMAIL SENT
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<ForgotPasswordForm
|
|
|
|
|
clearErrors={clearErrors}
|
|
|
|
|
error={error}
|
|
|
|
|
onSubmit={this.onSubmit}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2016-09-14 20:31:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render () {
|
2016-09-16 21:19:37 +00:00
|
|
|
|
const leadText = 'If you’ve forgotten your password enter your email below and we will email you a link so that you can reset your password.';
|
|
|
|
|
const whiteBoxOverrideStyles = {
|
|
|
|
|
headerWrapper: { textAlign: 'left' },
|
|
|
|
|
};
|
2016-09-14 20:31:54 +00:00
|
|
|
|
|
|
|
|
|
return (
|
2016-09-16 21:19:37 +00:00
|
|
|
|
<StackedWhiteBoxes
|
|
|
|
|
headerText="Forgot Password"
|
|
|
|
|
leadText={leadText}
|
|
|
|
|
previousLocation="/login"
|
|
|
|
|
style={whiteBoxOverrideStyles}
|
|
|
|
|
>
|
|
|
|
|
{this.renderContent()}
|
|
|
|
|
</StackedWhiteBoxes>
|
2016-09-14 20:31:54 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-16 13:55:46 +00:00
|
|
|
|
const mapStateToProps = (state) => {
|
|
|
|
|
return state.components.ForgotPasswordPage;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps)(ForgotPasswordPage);
|