Add currentUserHasOrders info to ProfilePage

Verification props to ProfilePage
This commit is contained in:
Vesa Luusua 2017-09-13 21:30:25 +03:00
parent 4e9a84ee17
commit 180951a942
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 ProfilePageComponent = props => {
authInProgress,
currentUser,
currentUserHasListings,
currentUserHasOrders,
history,
isAuthenticated,
location,
@ -21,6 +23,9 @@ export const ProfilePageComponent = props => {
onLogout,
onManageDisableScrolling,
params,
sendVerificationEmailInProgress,
sendVerificationEmailError,
onResendVerificationEmail,
} = props;
return (
@ -33,12 +38,16 @@ export const ProfilePageComponent = 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>
);
@ -47,8 +56,10 @@ export const ProfilePageComponent = props => {
ProfilePageComponent.defaultProps = {
authInfoError: null,
currentUser: null,
currentUserHasOrders: null,
logoutError: null,
notificationCount: 0,
sendVerificationEmailError: null,
};
const { bool, func, instanceOf, number, object, shape, string } = PropTypes;
@ -58,12 +69,16 @@ ProfilePageComponent.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,
params: shape({ displayName: string.isRequired }).isRequired,
sendVerificationEmailInProgress: bool.isRequired,
sendVerificationEmailError: instanceOf(Error),
onResendVerificationEmail: func.isRequired,
// from withRouter
history: shape({
@ -79,17 +94,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,
};
};
@ -97,6 +118,7 @@ const mapDispatchToProps = dispatch => ({
onLogout: historyPush => dispatch(logout(historyPush)),
onManageDisableScrolling: (componentId, disableScrolling) =>
dispatch(manageDisableScrolling(componentId, disableScrolling)),
onResendVerificationEmail: () => dispatch(sendVerificationEmail()),
});
const ProfilePage = compose(connect(mapStateToProps, mapDispatchToProps), withRouter)(

View file

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

View file

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