2016-10-12 23:19:43 +02:00
|
|
|
import React, { PropTypes } from 'react';
|
2016-10-12 18:02:46 +02:00
|
|
|
import { Link } from 'react-router';
|
2016-10-12 20:25:24 +02:00
|
|
|
import * as UserActions from '../../User/actions';
|
|
|
|
import { bindActionCreators } from 'redux';
|
|
|
|
import { reduxForm } from 'redux-form';
|
|
|
|
import ResetPasswordForm from './ResetPasswordForm';
|
2016-10-12 23:19:43 +02:00
|
|
|
import classNames from 'classnames';
|
2016-10-12 18:02:46 +02:00
|
|
|
|
|
|
|
class ResetPasswordView extends React.Component {
|
2016-10-12 23:19:43 +02:00
|
|
|
componentWillMount() {
|
|
|
|
this.props.resetPasswordReset();
|
|
|
|
}
|
|
|
|
|
2016-10-12 18:02:46 +02:00
|
|
|
componentDidMount() {
|
2016-10-12 20:25:24 +02:00
|
|
|
this.refs.resetPassword.focus();
|
2016-10-12 18:02:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2016-10-12 23:19:43 +02:00
|
|
|
const resetPasswordClass = classNames({
|
|
|
|
'reset-password': true,
|
2016-10-14 18:08:08 +02:00
|
|
|
'reset-password--submitted': this.props.user.resetPasswordInitiate
|
2016-10-12 23:19:43 +02:00
|
|
|
});
|
2016-10-12 18:02:46 +02:00
|
|
|
return (
|
2016-10-12 23:19:43 +02:00
|
|
|
<div className={resetPasswordClass} ref="resetPassword" tabIndex="0">
|
2016-10-12 20:25:24 +02:00
|
|
|
<h1>Reset Your Password</h1>
|
|
|
|
<ResetPasswordForm {...this.props} />
|
2016-10-12 23:19:43 +02:00
|
|
|
<p className="reset-password__submitted">
|
|
|
|
Your password reset email should arrive shortly. If you don't see it, check
|
|
|
|
in your spam folder as sometimes it can end up there.
|
|
|
|
</p>
|
|
|
|
<p className="form__navigation-options">
|
|
|
|
<Link className="form__login-button" to="/login">Login</Link>
|
|
|
|
or
|
|
|
|
<Link className="form__signup-button" to="/signup">Sign up</Link>
|
|
|
|
</p>
|
2016-10-12 18:02:46 +02:00
|
|
|
<Link className="form__cancel-button" to="/">Cancel</Link>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2016-10-12 20:25:24 +02:00
|
|
|
}
|
|
|
|
|
2016-10-12 23:19:43 +02:00
|
|
|
ResetPasswordView.propTypes = {
|
|
|
|
resetPasswordReset: PropTypes.func.isRequired,
|
|
|
|
user: PropTypes.shape({
|
2016-10-14 18:08:08 +02:00
|
|
|
resetPasswordInitiate: PropTypes.bool
|
2016-10-12 23:19:43 +02:00
|
|
|
}).isRequired,
|
|
|
|
};
|
|
|
|
|
2016-10-12 20:25:24 +02:00
|
|
|
function mapStateToProps(state) {
|
|
|
|
return {
|
|
|
|
user: state.user
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function mapDispatchToProps(dispatch) {
|
|
|
|
return bindActionCreators(UserActions, dispatch);
|
|
|
|
}
|
|
|
|
|
|
|
|
function validate(formProps) {
|
|
|
|
const errors = {};
|
|
|
|
if (!formProps.email) {
|
2016-10-12 23:19:43 +02:00
|
|
|
errors.email = 'Please enter an email';
|
2016-10-12 20:25:24 +02:00
|
|
|
}
|
|
|
|
return errors;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default reduxForm({
|
|
|
|
form: 'reset-password',
|
2016-10-12 23:19:43 +02:00
|
|
|
fields: ['email'],
|
2016-10-12 20:25:24 +02:00
|
|
|
validate
|
|
|
|
}, mapStateToProps, mapDispatchToProps)(ResetPasswordView);
|