mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-31 02:26:50 +10:00
OrderPage: pass Topbar props
This commit is contained in:
parent
d397f11cd2
commit
b75ac9c444
3 changed files with 76 additions and 9 deletions
|
|
@ -8,6 +8,7 @@ import { NamedRedirect, OrderDetailsPanel, PageLayout, Topbar } from '../../comp
|
|||
import * as propTypes from '../../util/propTypes';
|
||||
import { ensureListing, ensureTransaction } from '../../util/data';
|
||||
import { getMarketplaceEntities } from '../../ducks/marketplaceData.duck';
|
||||
import { logout, authenticationInProgress } from '../../ducks/Auth.duck';
|
||||
import { manageDisableScrolling, isScrollingDisabled } from '../../ducks/UI.duck';
|
||||
import { loadData } from './OrderPage.duck';
|
||||
|
||||
|
|
@ -17,14 +18,20 @@ import css from './OrderPage.css';
|
|||
// It show loading data text or OrderDetailsPanel (and later also another panel for messages).
|
||||
export const OrderPageComponent = props => {
|
||||
const {
|
||||
authInProgress,
|
||||
currentUser,
|
||||
currentUserHasListings,
|
||||
fetchOrderError,
|
||||
intl,
|
||||
params,
|
||||
transaction,
|
||||
scrollingDisabled,
|
||||
history,
|
||||
intl,
|
||||
isAuthenticated,
|
||||
location,
|
||||
notificationCount,
|
||||
onLogout,
|
||||
onManageDisableScrolling,
|
||||
params,
|
||||
scrollingDisabled,
|
||||
transaction,
|
||||
} = props;
|
||||
const currentTransaction = ensureTransaction(transaction);
|
||||
const currentListing = ensureListing(currentTransaction.listing);
|
||||
|
|
@ -60,20 +67,41 @@ export const OrderPageComponent = props => {
|
|||
title={intl.formatMessage({ id: 'OrderPage.title' }, { listingTitle })}
|
||||
scrollingDisabled={scrollingDisabled}
|
||||
>
|
||||
<Topbar history={history} location={location} />
|
||||
<Topbar
|
||||
isAuthenticated={isAuthenticated}
|
||||
authInProgress={authInProgress}
|
||||
currentUser={currentUser}
|
||||
currentUserHasListings={currentUserHasListings}
|
||||
notificationCount={notificationCount}
|
||||
history={history}
|
||||
location={location}
|
||||
onLogout={onLogout}
|
||||
onManageDisableScrolling={onManageDisableScrolling}
|
||||
/>
|
||||
{panel}
|
||||
</PageLayout>
|
||||
);
|
||||
};
|
||||
|
||||
OrderPageComponent.defaultProps = { transaction: null, currentUser: null, fetchOrderError: null };
|
||||
OrderPageComponent.defaultProps = {
|
||||
currentUser: null,
|
||||
fetchOrderError: null,
|
||||
notificationCount: 0,
|
||||
transaction: null,
|
||||
};
|
||||
|
||||
const { bool, func, instanceOf, oneOf, shape, string } = PropTypes;
|
||||
const { bool, func, instanceOf, number, oneOf, shape, string } = PropTypes;
|
||||
|
||||
OrderPageComponent.propTypes = {
|
||||
authInProgress: bool.isRequired,
|
||||
currentUser: propTypes.currentUser,
|
||||
currentUserHasListings: bool.isRequired,
|
||||
fetchOrderError: instanceOf(Error),
|
||||
intl: intlShape.isRequired,
|
||||
isAuthenticated: bool.isRequired,
|
||||
notificationCount: number,
|
||||
onLogout: func.isRequired,
|
||||
onManageDisableScrolling: func.isRequired,
|
||||
params: shape({ id: string }).isRequired,
|
||||
scrollingDisabled: bool.isRequired,
|
||||
tab: oneOf(['details', 'discussion']).isRequired,
|
||||
|
|
@ -90,7 +118,12 @@ OrderPageComponent.propTypes = {
|
|||
|
||||
const mapStateToProps = state => {
|
||||
const { fetchOrderError, transactionRef } = state.OrderPage;
|
||||
const { currentUser } = state.user;
|
||||
const { isAuthenticated } = state.Auth;
|
||||
const {
|
||||
currentUser,
|
||||
currentUserHasListings,
|
||||
currentUserNotificationCount: notificationCount,
|
||||
} = state.user;
|
||||
|
||||
const transactions = getMarketplaceEntities(state, transactionRef ? [transactionRef] : []);
|
||||
const transaction = transactions.length > 0 ? transactions[0] : null;
|
||||
|
|
@ -98,12 +131,17 @@ const mapStateToProps = state => {
|
|||
return {
|
||||
transaction,
|
||||
fetchOrderError,
|
||||
isAuthenticated,
|
||||
authInProgress: authenticationInProgress(state),
|
||||
currentUser,
|
||||
currentUserHasListings,
|
||||
notificationCount,
|
||||
scrollingDisabled: isScrollingDisabled(state),
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
onLogout: historyPush => dispatch(logout(historyPush)),
|
||||
onManageDisableScrolling: (componentId, disableScrolling) =>
|
||||
dispatch(manageDisableScrolling(componentId, disableScrolling)),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import {
|
|||
import { renderShallow } from '../../util/test-helpers';
|
||||
import { OrderPageComponent } from './OrderPage';
|
||||
|
||||
const noop = () => null;
|
||||
|
||||
describe('OrderPage', () => {
|
||||
it('matches snapshot', () => {
|
||||
const txId = 'tx-order-1';
|
||||
|
|
@ -27,6 +29,11 @@ describe('OrderPage', () => {
|
|||
});
|
||||
|
||||
const props = {
|
||||
authInProgress: false,
|
||||
currentUserHasListings: false,
|
||||
isAuthenticated: false,
|
||||
onLogout: noop,
|
||||
onManageDisableScrolling: noop,
|
||||
currentUser: createCurrentUser('customer1'),
|
||||
params: { id: txId },
|
||||
transaction,
|
||||
|
|
|
|||
|
|
@ -3,16 +3,38 @@ exports[`OrderPage matches snapshot 1`] = `
|
|||
scrollingDisabled={false}
|
||||
title="OrderPage.title">
|
||||
<Topbar
|
||||
authInProgress={false}
|
||||
currentUser={
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"email": "customer1@example.com",
|
||||
"profile": Object {
|
||||
"firstName": "customer1 first name",
|
||||
"lastName": "customer1 last name",
|
||||
},
|
||||
"stripeConnected": true,
|
||||
},
|
||||
"id": UUID {
|
||||
"uuid": "customer1",
|
||||
},
|
||||
"type": "user",
|
||||
}
|
||||
}
|
||||
currentUserHasListings={false}
|
||||
history={
|
||||
Object {
|
||||
"push": [Function],
|
||||
}
|
||||
}
|
||||
isAuthenticated={false}
|
||||
location={
|
||||
Object {
|
||||
"search": "",
|
||||
}
|
||||
} />
|
||||
}
|
||||
notificationCount={0}
|
||||
onLogout={[Function]}
|
||||
onManageDisableScrolling={[Function]} />
|
||||
<OrderDetailsPanel
|
||||
className="undefined"
|
||||
lastTransition={null}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue