p5.js-web-editor/client/modules/IDE/components/ResetPasswordView.jsx

72 lines
2 KiB
React
Raw Normal View History

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';
import classNames from 'classnames';
2016-10-12 18:02:46 +02:00
class ResetPasswordView extends React.Component {
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() {
const resetPasswordClass = classNames({
'reset-password': true,
2016-10-14 18:08:08 +02:00
'reset-password--submitted': this.props.user.resetPasswordInitiate
});
2016-10-12 18:02:46 +02:00
return (
<div className={resetPasswordClass} ref="resetPassword" tabIndex="0">
2016-10-12 20:25:24 +02:00
<h1>Reset Your Password</h1>
<ResetPasswordForm {...this.props} />
<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>
&nbsp;or&nbsp;
<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
}
ResetPasswordView.propTypes = {
resetPasswordReset: PropTypes.func.isRequired,
user: PropTypes.shape({
2016-10-14 18:08:08 +02:00
resetPasswordInitiate: PropTypes.bool
}).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) {
errors.email = 'Please enter an email';
2016-10-12 20:25:24 +02:00
}
return errors;
}
export default reduxForm({
form: 'reset-password',
fields: ['email'],
2016-10-12 20:25:24 +02:00
validate
}, mapStateToProps, mapDispatchToProps)(ResetPasswordView);