From cda2b7b115cc4fff54ab6a54ef246316f19552c3 Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Wed, 11 Oct 2017 20:14:07 +0300 Subject: [PATCH] PasswordChangePage uses TopbarContainer --- .../PasswordChangePage/PasswordChangePage.js | 91 ++++--------------- .../PasswordChangePage.test.js.snap | 26 +----- 2 files changed, 19 insertions(+), 98 deletions(-) diff --git a/src/containers/PasswordChangePage/PasswordChangePage.js b/src/containers/PasswordChangePage/PasswordChangePage.js index 55ccfe02..4d74e257 100644 --- a/src/containers/PasswordChangePage/PasswordChangePage.js +++ b/src/containers/PasswordChangePage/PasswordChangePage.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 } from 'react-intl'; import * as propTypes from '../../util/propTypes'; -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 { ContentWrapper, LayoutSideNavigation, Page, SideNavWrapper, TabNav, - Topbar, TopbarWrapper, UserNav, } from '../../components'; -import { PasswordChangeForm } from '../../containers'; +import { PasswordChangeForm, TopbarContainer } from '../../containers'; import { changePassword, changePasswordClear } from './PasswordChangePage.duck'; import css from './PasswordChangePage.css'; @@ -25,25 +21,14 @@ import css from './PasswordChangePage.css'; export const PasswordChangePageComponent = props => { const { authInfoError, - authInProgress, changePasswordError, changePasswordInProgress, currentUser, - currentUserHasListings, - currentUserHasOrders, - history, - isAuthenticated, - location, logoutError, - notificationCount, onChange, - onLogout, - onManageDisableScrolling, onSubmitChangePassword, passwordChanged, - sendVerificationEmailInProgress, - sendVerificationEmailError, - onResendVerificationEmail, + scrollingDisabled, } = props; const tabs = [ @@ -76,26 +61,18 @@ export const PasswordChangePageComponent = props => { : null; return ( - + - @@ -119,86 +96,50 @@ PasswordChangePageComponent.defaultProps = { authInfoError: null, changePasswordError: null, currentUser: null, - currentUserHasOrders: null, logoutError: null, - notificationCount: 0, - sendVerificationEmailError: null, }; -const { bool, func, instanceOf, number, object, shape } = PropTypes; +const { bool, func, instanceOf } = PropTypes; PasswordChangePageComponent.propTypes = { authInfoError: instanceOf(Error), - authInProgress: bool.isRequired, changePasswordError: instanceOf(Error), changePasswordInProgress: bool.isRequired, currentUser: propTypes.currentUser, - currentUserHasListings: bool.isRequired, - currentUserHasOrders: bool, - isAuthenticated: bool.isRequired, logoutError: instanceOf(Error), - notificationCount: number, onChange: func.isRequired, - onLogout: func.isRequired, - onManageDisableScrolling: func.isRequired, onSubmitChangePassword: func.isRequired, passwordChanged: bool.isRequired, - sendVerificationEmailInProgress: bool.isRequired, - sendVerificationEmailError: instanceOf(Error), - onResendVerificationEmail: func.isRequired, - - // from withRouter - history: shape({ - push: func.isRequired, - }).isRequired, - location: shape({ state: object }).isRequired, + scrollingDisabled: bool.isRequired, }; const mapStateToProps = state => { - // Page needs authInfoError and logoutError, Topbar needs isAuthenticated - const { authInfoError, isAuthenticated, logoutError } = state.Auth; + // Page needs authInfoError and logoutError + const { authInfoError, logoutError } = state.Auth; // Topbar needs user info. const { changePasswordError, changePasswordInProgress, passwordChanged, } = state.PasswordChangePage; - const { - currentUser, - currentUserHasListings, - currentUserHasOrders, - currentUserNotificationCount: notificationCount, - sendVerificationEmailInProgress, - sendVerificationEmailError, - } = state.user; + const { currentUser } = state.user; return { authInfoError, - authInProgress: authenticationInProgress(state), changePasswordError, changePasswordInProgress, currentUser, - currentUserHasListings, - currentUserHasOrders, - notificationCount, - isAuthenticated, logoutError, passwordChanged, scrollingDisabled: isScrollingDisabled(state), - sendVerificationEmailInProgress, - sendVerificationEmailError, }; }; const mapDispatchToProps = dispatch => ({ onChange: () => dispatch(changePasswordClear()), - onLogout: historyPush => dispatch(logout(historyPush)), - onManageDisableScrolling: (componentId, disableScrolling) => - dispatch(manageDisableScrolling(componentId, disableScrolling)), - onResendVerificationEmail: () => dispatch(sendVerificationEmail()), onSubmitChangePassword: values => dispatch(changePassword(values)), }); -const PasswordChangePage = compose(connect(mapStateToProps, mapDispatchToProps), withRouter)( +const PasswordChangePage = compose(connect(mapStateToProps, mapDispatchToProps))( PasswordChangePageComponent ); diff --git a/src/containers/PasswordChangePage/__snapshots__/PasswordChangePage.test.js.snap b/src/containers/PasswordChangePage/__snapshots__/PasswordChangePage.test.js.snap index a8a2d66e..4676d368 100644 --- a/src/containers/PasswordChangePage/__snapshots__/PasswordChangePage.test.js.snap +++ b/src/containers/PasswordChangePage/__snapshots__/PasswordChangePage.test.js.snap @@ -2,6 +2,7 @@ exports[`PasswordChangePage matches snapshot 1`] = ` - +