mirror of
https://github.com/wassname/talk.git
synced 2026-09-12 13:01:11 +08:00
More refactoring
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { withForgotPassword } from 'coral-framework/hocs';
|
||||
import { compose } from 'recompose';
|
||||
import ForgotPassword from '../components/ForgotPassword';
|
||||
import { connect } from 'plugin-api/beta/client/hocs';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import * as views from '../enums/views';
|
||||
import { setView, setEmail } from '../actions';
|
||||
|
||||
class ForgotPasswordContainer extends Component {
|
||||
handleSubmit = () => {
|
||||
this.props.forgotPassword(this.props.email);
|
||||
};
|
||||
|
||||
handleSignUpLink = () => {
|
||||
this.props.setView(views.SIGN_UP);
|
||||
};
|
||||
|
||||
handleSignInLink = () => {
|
||||
this.props.setView(views.SIGN_IN);
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<ForgotPassword
|
||||
onSubmit={this.handleSubmit}
|
||||
onEmailChange={this.props.setEmail}
|
||||
email={this.props.email}
|
||||
errorMessage={this.props.errorMessage}
|
||||
success={this.props.success}
|
||||
onSignInLink={this.handleSignInLink}
|
||||
onSignUpLink={this.handleSignUpLink}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ForgotPasswordContainer.propTypes = {
|
||||
success: PropTypes.bool.isRequired,
|
||||
forgotPassword: PropTypes.func.isRequired,
|
||||
errorMessage: PropTypes.string.isRequired,
|
||||
setView: PropTypes.func.isRequired,
|
||||
email: PropTypes.string.isRequired,
|
||||
setEmail: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
const mapStateToProps = ({ talkPluginAuth: state }) => ({
|
||||
email: state.email,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators(
|
||||
{
|
||||
setView,
|
||||
setEmail,
|
||||
},
|
||||
dispatch
|
||||
);
|
||||
|
||||
export default compose(
|
||||
connect(mapStateToProps, mapDispatchToProps),
|
||||
withForgotPassword
|
||||
)(ForgotPasswordContainer);
|
||||
Reference in New Issue
Block a user