PasswordResetPage uses TopbarContainer

This commit is contained in:
Vesa Luusua 2017-10-11 20:14:38 +03:00
parent 10079dcda0
commit f247365348

View file

@ -3,19 +3,14 @@ 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 { Page, Topbar, NamedLink, IconKeys, IconKeysSuccess } from '../../components';
import { PasswordResetForm } from '../../containers';
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 { parse } from '../../util/urlHelpers';
import { Page, NamedLink, IconKeys, IconKeysSuccess } from '../../components';
import { PasswordResetForm, TopbarContainer } from '../../containers';
import { resetPassword } from './PasswordResetPage.duck';
import css from './PasswordResetPage.css';
const { bool, func, instanceOf, number, object, shape, string } = PropTypes;
const parseUrlParams = location => {
const params = parse(location.search);
const { t: token, e: email } = params;
@ -30,25 +25,13 @@ export class PasswordResetPageComponent extends Component {
render() {
const {
authInfoError,
authInProgress,
currentUser,
currentUserHasListings,
currentUserHasOrders,
intl,
isAuthenticated,
logoutError,
notificationCount,
onLogout,
onManageDisableScrolling,
scrollingDisabled,
location,
history,
resetPasswordInProgress,
resetPasswordError,
onSubmitPassword,
sendVerificationEmailInProgress,
sendVerificationEmailError,
onResendVerificationEmail,
} = this.props;
const title = intl.formatMessage({
@ -133,21 +116,7 @@ export class PasswordResetPageComponent extends Component {
logoutError={logoutError}
scrollingDisabled={scrollingDisabled}
>
<Topbar
isAuthenticated={isAuthenticated}
authInProgress={authInProgress}
currentUser={currentUser}
currentUserHasListings={currentUserHasListings}
currentUserHasOrders={currentUserHasOrders}
notificationCount={notificationCount}
history={history}
location={location}
onLogout={onLogout}
onManageDisableScrolling={onManageDisableScrolling}
onResendVerificationEmail={onResendVerificationEmail}
sendVerificationEmailInProgress={sendVerificationEmailInProgress}
sendVerificationEmailError={sendVerificationEmailError}
/>
<TopbarContainer />
<div className={css.root}>
{content}
</div>
@ -158,36 +127,21 @@ export class PasswordResetPageComponent extends Component {
PasswordResetPageComponent.defaultProps = {
authInfoError: null,
currentUser: null,
currentUserHasOrders: null,
logoutError: null,
notificationCount: 0,
resetPasswordError: null,
sendVerificationEmailError: null,
};
const { bool, func, instanceOf, shape, string } = PropTypes;
PasswordResetPageComponent.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,
scrollingDisabled: bool.isRequired,
sendVerificationEmailInProgress: bool.isRequired,
sendVerificationEmailError: instanceOf(Error),
onResendVerificationEmail: func.isRequired,
resetPasswordInProgress: bool.isRequired,
resetPasswordError: instanceOf(Error),
onSubmitPassword: func.isRequired,
// from withRouter
history: object.isRequired,
location: shape({
search: string,
}).isRequired,
@ -197,42 +151,18 @@ PasswordResetPageComponent.propTypes = {
};
const mapStateToProps = state => {
const {
authInfoError,
isAuthenticated,
logoutError,
} = state.Auth;
const {
currentUser,
currentUserHasListings,
currentUserHasOrders,
currentUserNotificationCount: notificationCount,
sendVerificationEmailInProgress,
sendVerificationEmailError,
} = state.user;
const { authInfoError, logoutError } = state.Auth;
const { resetPasswordInProgress, resetPasswordError } = state.PasswordResetPage;
return {
authInfoError,
authInProgress: authenticationInProgress(state),
currentUser,
currentUserHasListings,
currentUserHasOrders,
isAuthenticated,
logoutError,
notificationCount,
scrollingDisabled: isScrollingDisabled(state),
resetPasswordInProgress,
resetPasswordError,
sendVerificationEmailInProgress,
sendVerificationEmailError,
};
};
const mapDispatchToProps = dispatch => ({
onLogout: () => dispatch(logout()),
onManageDisableScrolling: (componentId, disableScrolling) =>
dispatch(manageDisableScrolling(componentId, disableScrolling)),
onResendVerificationEmail: () => dispatch(sendVerificationEmail()),
onSubmitPassword: (email, token, password) => dispatch(resetPassword(email, token, password)),
});