mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-27 19:42:11 +10:00
PasswordChangePage uses TopbarContainer
This commit is contained in:
parent
f3848b2799
commit
cda2b7b115
2 changed files with 19 additions and 98 deletions
|
|
@ -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 (
|
||||
<Page authInfoError={authInfoError} logoutError={logoutError} title="Contact details">
|
||||
<Page
|
||||
authInfoError={authInfoError}
|
||||
logoutError={logoutError}
|
||||
title="Contact details"
|
||||
scrollingDisabled={scrollingDisabled}
|
||||
>
|
||||
<LayoutSideNavigation>
|
||||
<TopbarWrapper>
|
||||
<Topbar
|
||||
authInProgress={authInProgress}
|
||||
<TopbarContainer
|
||||
currentPage="PasswordChangePage"
|
||||
currentUser={currentUser}
|
||||
currentUserHasListings={currentUserHasListings}
|
||||
currentUserHasOrders={currentUserHasOrders}
|
||||
desktopClassName={css.desktopTopbar}
|
||||
history={history}
|
||||
isAuthenticated={isAuthenticated}
|
||||
location={location}
|
||||
mobileClassName={css.mobileTopbar}
|
||||
notificationCount={notificationCount}
|
||||
onLogout={onLogout}
|
||||
onManageDisableScrolling={onManageDisableScrolling}
|
||||
onResendVerificationEmail={onResendVerificationEmail}
|
||||
sendVerificationEmailInProgress={sendVerificationEmailInProgress}
|
||||
sendVerificationEmailError={sendVerificationEmailError}
|
||||
/>
|
||||
<UserNav selectedPageName="PasswordChangePage" />
|
||||
</TopbarWrapper>
|
||||
|
|
@ -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
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ exports[`PasswordChangePage matches snapshot 1`] = `
|
|||
<Page
|
||||
authInfoError={null}
|
||||
logoutError={null}
|
||||
scrollingDisabled={false}
|
||||
title="Contact details">
|
||||
<LayoutSideNavigation
|
||||
className={null}
|
||||
|
|
@ -10,29 +11,8 @@ exports[`PasswordChangePage matches snapshot 1`] = `
|
|||
<TopbarWrapper
|
||||
className={null}
|
||||
rootClassName={null}>
|
||||
<Topbar
|
||||
authInProgress={false}
|
||||
currentPage="PasswordChangePage"
|
||||
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))
|
||||
currentPage="PasswordChangePage" />
|
||||
<UserNav
|
||||
className={null}
|
||||
rootClassName={null}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue