Add currentUserHasOrders info to SecurityPage

Verification props to SecurityPage
This commit is contained in:
Vesa Luusua 2017-09-13 21:37:22 +03:00
parent 01a8d2ed8e
commit 580ab39e17
3 changed files with 29 additions and 1 deletions

View file

@ -3,6 +3,7 @@ import { compose } from 'redux';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
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 { PageLayout, Topbar } from '../../components';
@ -13,6 +14,7 @@ export const SecurityPageComponent = props => {
authInProgress,
currentUser,
currentUserHasListings,
currentUserHasOrders,
history,
isAuthenticated,
location,
@ -20,6 +22,9 @@ export const SecurityPageComponent = props => {
notificationCount,
onLogout,
onManageDisableScrolling,
sendVerificationEmailInProgress,
sendVerificationEmailError,
onResendVerificationEmail,
} = props;
return (
@ -28,12 +33,16 @@ export const SecurityPageComponent = props => {
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}
/>
</PageLayout>
);
@ -42,8 +51,10 @@ export const SecurityPageComponent = props => {
SecurityPageComponent.defaultProps = {
authInfoError: null,
currentUser: null,
currentUserHasOrders: null,
logoutError: null,
notificationCount: 0,
sendVerificationEmailError: null,
};
const { bool, func, instanceOf, number, object, shape } = PropTypes;
@ -53,11 +64,15 @@ SecurityPageComponent.propTypes = {
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,
// from withRouter
history: shape({
@ -73,17 +88,23 @@ const mapStateToProps = state => {
const {
currentUser,
currentUserHasListings,
currentUserHasOrders,
currentUserNotificationCount: notificationCount,
sendVerificationEmailInProgress,
sendVerificationEmailError,
} = state.user;
return {
authInfoError,
authInProgress: authenticationInProgress(state),
currentUser,
currentUserHasListings,
currentUserHasOrders,
currentUserNotificationCount: notificationCount,
isAuthenticated,
logoutError,
scrollingDisabled: isScrollingDisabled(state),
sendVerificationEmailInProgress,
sendVerificationEmailError,
};
};
@ -91,6 +112,7 @@ const mapDispatchToProps = dispatch => ({
onLogout: historyPush => dispatch(logout(historyPush)),
onManageDisableScrolling: (componentId, disableScrolling) =>
dispatch(manageDisableScrolling(componentId, disableScrolling)),
onResendVerificationEmail: () => dispatch(sendVerificationEmail()),
});
const SecurityPage = compose(connect(mapStateToProps, mapDispatchToProps), withRouter)(

View file

@ -17,6 +17,8 @@ describe('SecurityPage', () => {
isAuthenticated={false}
onLogout={noop}
onManageDisableScrolling={noop}
sendVerificationEmailInProgress={false}
onResendVerificationEmail={noop}
/>
);
expect(tree).toMatchSnapshot();

View file

@ -7,6 +7,7 @@ exports[`SecurityPage matches snapshot 1`] = `
authInProgress={false}
currentUser={null}
currentUserHasListings={false}
currentUserHasOrders={null}
history={
Object {
"push": [Function],
@ -20,6 +21,9 @@ exports[`SecurityPage matches snapshot 1`] = `
}
notificationCount={0}
onLogout={[Function]}
onManageDisableScrolling={[Function]} />
onManageDisableScrolling={[Function]}
onResendVerificationEmail={[Function]}
sendVerificationEmailError={null}
sendVerificationEmailInProgress={false} />
</withRouter(PageLayout)>
`;