PasswordRecoveryPage uses TopbarContainer

This commit is contained in:
Vesa Luusua 2017-10-11 20:14:21 +03:00
parent cda2b7b115
commit 10079dcda0
2 changed files with 11 additions and 107 deletions

View file

@ -1,23 +1,19 @@
import React, { PropTypes } from 'react';
import { compose } from 'redux';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import { FormattedMessage, injectIntl, intlShape } from 'react-intl';
import * as propTypes from '../../util/propTypes';
import {
isPasswordRecoveryEmailNotFoundError,
isPasswordRecoveryEmailNotVerifiedError,
} from '../../util/errors';
import { sendVerificationEmail } from '../../ducks/user.duck';
import { logout, authenticationInProgress } from '../../ducks/Auth.duck';
import { manageDisableScrolling, isScrollingDisabled } from '../../ducks/UI.duck';
import { isScrollingDisabled } from '../../ducks/UI.duck';
import {
recoverPassword,
retypePasswordRecoveryEmail,
clearPasswordRecoveryError,
} from './PasswordRecoveryPage.duck';
import { Page, Topbar, InlineTextButton, IconKeys } from '../../components';
import { PasswordRecoveryForm } from '../../containers';
import { Page, InlineTextButton, IconKeys } from '../../components';
import { PasswordRecoveryForm, TopbarContainer } from '../../containers';
import DoorIcon from './DoorIcon';
import css from './PasswordRecoveryPage.css';
@ -25,20 +21,7 @@ import css from './PasswordRecoveryPage.css';
export const PasswordRecoveryPageComponent = props => {
const {
authInfoError,
authInProgress,
currentUser,
currentUserHasListings,
currentUserHasOrders,
history,
isAuthenticated,
location,
logoutError,
notificationCount,
onLogout,
onManageDisableScrolling,
sendVerificationEmailInProgress,
sendVerificationEmailError,
onResendVerificationEmail,
initialEmail,
submittedEmail,
recoveryError,
@ -163,57 +146,28 @@ export const PasswordRecoveryPageComponent = props => {
return (
<Page authInfoError={authInfoError} logoutError={logoutError} title={title}>
<Topbar
authInProgress={authInProgress}
currentUser={currentUser}
currentUserHasListings={currentUserHasListings}
currentUserHasOrders={currentUserHasOrders}
history={history}
isAuthenticated={isAuthenticated}
location={location}
notificationCount={notificationCount}
onLogout={onLogout}
onManageDisableScrolling={onManageDisableScrolling}
onResendVerificationEmail={onResendVerificationEmail}
sendVerificationEmailInProgress={sendVerificationEmailInProgress}
sendVerificationEmailError={sendVerificationEmailError}
/>
<TopbarContainer />
<div className={css.root}>
{content}
</div>
</Page>
);
};
PasswordRecoveryPageComponent.defaultProps = {
authInfoError: null,
currentUser: null,
currentUserHasOrders: null,
logoutError: null,
notificationCount: 0,
sendVerificationEmailError: null,
initialEmail: null,
submittedEmail: null,
recoveryError: null,
};
const { bool, func, instanceOf, number, object, shape, string } = PropTypes;
const { bool, func, instanceOf, string } = PropTypes;
PasswordRecoveryPageComponent.propTypes = {
authInfoError: instanceOf(Error),
authInProgress: bool.isRequired,
currentUser: propTypes.currentUser,
currentUserHasListings: bool.isRequired,
currentUserHasOrders: bool,
isAuthenticated: bool.isRequired,
logoutError: instanceOf(Error),
notificationCount: number,
onLogout: func.isRequired,
onManageDisableScrolling: func.isRequired,
sendVerificationEmailInProgress: bool.isRequired,
sendVerificationEmailError: instanceOf(Error),
onResendVerificationEmail: func.isRequired,
initialEmail: string,
submittedEmail: string,
recoveryError: instanceOf(Error),
@ -225,26 +179,11 @@ PasswordRecoveryPageComponent.propTypes = {
// from injectIntl
intl: intlShape.isRequired,
// from withRouter
history: shape({
push: func.isRequired,
}).isRequired,
location: shape({ state: object }).isRequired,
};
const mapStateToProps = state => {
// Page needs authInfoError and logoutError, Topbar needs isAuthenticated
const { authInfoError, isAuthenticated, logoutError } = state.Auth;
// Topbar needs user info.
const {
currentUser,
currentUserHasListings,
currentUserHasOrders,
currentUserNotificationCount: notificationCount,
sendVerificationEmailInProgress,
sendVerificationEmailError,
} = state.user;
// Page needs authInfoError and logoutError
const { authInfoError, logoutError } = state.Auth;
const {
initialEmail,
@ -255,16 +194,8 @@ const mapStateToProps = state => {
} = state.PasswordRecoveryPage;
return {
authInfoError,
authInProgress: authenticationInProgress(state),
currentUser,
currentUserHasListings,
currentUserHasOrders,
notificationCount,
isAuthenticated,
logoutError,
scrollingDisabled: isScrollingDisabled(state),
sendVerificationEmailInProgress,
sendVerificationEmailError,
initialEmail,
submittedEmail,
recoveryError,
@ -274,19 +205,13 @@ const mapStateToProps = state => {
};
const mapDispatchToProps = dispatch => ({
onLogout: historyPush => dispatch(logout(historyPush)),
onManageDisableScrolling: (componentId, disableScrolling) =>
dispatch(manageDisableScrolling(componentId, disableScrolling)),
onResendVerificationEmail: () => dispatch(sendVerificationEmail()),
onChange: () => dispatch(clearPasswordRecoveryError()),
onSubmitEmail: email => dispatch(recoverPassword(email)),
onRetypeEmail: () => dispatch(retypePasswordRecoveryEmail()),
});
const PasswordRecoveryPage = compose(
connect(mapStateToProps, mapDispatchToProps),
withRouter,
injectIntl
)(PasswordRecoveryPageComponent);
const PasswordRecoveryPage = compose(connect(mapStateToProps, mapDispatchToProps), injectIntl)(
PasswordRecoveryPageComponent
);
export default PasswordRecoveryPage;

View file

@ -3,28 +3,7 @@ exports[`ContactDetailsPage matches snapshot 1`] = `
authInfoError={null}
logoutError={null}
title="PasswordRecoveryPage.title">
<Topbar
authInProgress={false}
currentUser={null}
currentUserHasListings={false}
currentUserHasOrders={null}
history={
Object {
"push": [Function],
}
}
isAuthenticated={false}
location={
Object {
"search": "",
}
}
notificationCount={0}
onLogout={[Function]}
onManageDisableScrolling={[Function]}
onResendVerificationEmail={[Function]}
sendVerificationEmailError={null}
sendVerificationEmailInProgress={false} />
<Connect(withRouter(TopbarContainerComponent)) />
<div>
<div>
<IconKeys