From 10079dcda06b8b8790aae8d68b89a0c0361aab1d Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Wed, 11 Oct 2017 20:14:21 +0300 Subject: [PATCH] PasswordRecoveryPage uses TopbarContainer --- .../PasswordRecoveryPage.js | 95 ++----------------- .../PasswordRecoveryPage.test.js.snap | 23 +---- 2 files changed, 11 insertions(+), 107 deletions(-) diff --git a/src/containers/PasswordRecoveryPage/PasswordRecoveryPage.js b/src/containers/PasswordRecoveryPage/PasswordRecoveryPage.js index fedd4670..31642dd4 100644 --- a/src/containers/PasswordRecoveryPage/PasswordRecoveryPage.js +++ b/src/containers/PasswordRecoveryPage/PasswordRecoveryPage.js @@ -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 ( - +
{content}
-
); }; 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; diff --git a/src/containers/PasswordRecoveryPage/__snapshots__/PasswordRecoveryPage.test.js.snap b/src/containers/PasswordRecoveryPage/__snapshots__/PasswordRecoveryPage.test.js.snap index b62caa0a..2ebde760 100644 --- a/src/containers/PasswordRecoveryPage/__snapshots__/PasswordRecoveryPage.test.js.snap +++ b/src/containers/PasswordRecoveryPage/__snapshots__/PasswordRecoveryPage.test.js.snap @@ -3,28 +3,7 @@ exports[`ContactDetailsPage matches snapshot 1`] = ` authInfoError={null} logoutError={null} title="PasswordRecoveryPage.title"> - +