diff --git a/src/containers/OrderPage/OrderPage.js b/src/containers/OrderPage/OrderPage.js index fa4be7dc..6df2a3e5 100644 --- a/src/containers/OrderPage/OrderPage.js +++ b/src/containers/OrderPage/OrderPage.js @@ -13,7 +13,7 @@ import css from './OrderPage.css'; // OrderPage handles data loading // It show loading data text or OrderDetailsPanel (and later also another panel for messages). export const OrderPageComponent = props => { - const { currentUser, fetchOrderError, intl, transaction } = props; + const { currentUser, fetchOrderError, intl, params, transaction } = props; const currentTransaction = ensureTransaction(transaction); const currentListing = ensureListing(currentTransaction.listing); const title = currentListing.attributes.title; @@ -21,6 +21,7 @@ export const OrderPageComponent = props => { // Redirect users with someone else's direct link to their own inbox/orders page. const isDataAvailable = currentUser && currentTransaction.id && + currentTransaction.id.uuid === params.id && currentTransaction.customer && !fetchOrderError; const isOwnSale = isDataAvailable && currentUser.id.uuid === currentTransaction.customer.id.uuid; @@ -60,12 +61,13 @@ export const OrderPageComponent = props => { OrderPageComponent.defaultProps = { transaction: null, currentUser: null, fetchOrderError: null }; -const { instanceOf, oneOf } = PropTypes; +const { instanceOf, oneOf, shape, string } = PropTypes; OrderPageComponent.propTypes = { currentUser: propTypes.currentUser, fetchOrderError: instanceOf(Error), intl: intlShape.isRequired, + params: shape({ id: string }).isRequired, tab: oneOf(['details', 'discussion']).isRequired, transaction: propTypes.transaction, }; diff --git a/src/containers/OrderPage/OrderPage.test.js b/src/containers/OrderPage/OrderPage.test.js index 44ca6770..2276ac46 100644 --- a/src/containers/OrderPage/OrderPage.test.js +++ b/src/containers/OrderPage/OrderPage.test.js @@ -12,8 +12,9 @@ import { OrderPageComponent } from './OrderPage'; describe('OrderPage', () => { it('matches snapshot', () => { + const txId = 'tx-order-1'; const transaction = createTransaction({ - id: 'tx-order-1', + id: txId, state: 'state/preauthorized', booking: createBooking( 'booking1', @@ -27,6 +28,7 @@ describe('OrderPage', () => { const props = { currentUser: createCurrentUser('customer1'), + params: { id: txId }, transaction, tab: 'details', intl: fakeIntl, diff --git a/src/containers/SalePage/SalePage.js b/src/containers/SalePage/SalePage.js index 8ed790a6..87632ab5 100644 --- a/src/containers/SalePage/SalePage.js +++ b/src/containers/SalePage/SalePage.js @@ -14,7 +14,7 @@ import css from './SalePage.css'; // SalePage handles data loading // It show loading data text or SaleDetailsPanel (and later also another panel for messages). export const SalePageComponent = props => { - const { currentUser, fetchSaleError, intl, onAcceptSale, onRejectSale, transaction } = props; + const { currentUser, fetchSaleError, intl, onAcceptSale, onRejectSale, params, transaction } = props; const currentTransaction = ensureTransaction(transaction); const currentListing = ensureListing(currentTransaction.listing); const title = currentListing.attributes.title; @@ -22,6 +22,7 @@ export const SalePageComponent = props => { // Redirect users with someone else's direct link to their own inbox/sales page. const isDataAvailable = currentUser && currentTransaction.id && + currentTransaction.id.uuid === params.id && currentTransaction.provider && !fetchSaleError; const isOwnSale = isDataAvailable && currentUser.id.uuid === currentTransaction.provider.id.uuid; @@ -76,7 +77,7 @@ export const SalePageComponent = props => { SalePageComponent.defaultProps = { transaction: null, currentUser: null, fetchSaleError: null }; -const { func, instanceOf, oneOf } = PropTypes; +const { func, instanceOf, oneOf, shape, string } = PropTypes; SalePageComponent.propTypes = { currentUser: propTypes.currentUser, @@ -84,6 +85,7 @@ SalePageComponent.propTypes = { intl: intlShape.isRequired, onAcceptSale: func.isRequired, onRejectSale: func.isRequired, + params: shape({ id: string }).isRequired, tab: oneOf(['details', 'discussion']).isRequired, transaction: propTypes.transaction, }; diff --git a/src/containers/SalePage/SalePage.test.js b/src/containers/SalePage/SalePage.test.js index abf3f9f2..0613d3d7 100644 --- a/src/containers/SalePage/SalePage.test.js +++ b/src/containers/SalePage/SalePage.test.js @@ -12,8 +12,9 @@ import { SalePageComponent } from './SalePage'; describe('SalePage', () => { it('matches snapshot', () => { + const txId = 'tx-sale-1'; const transaction = createTransaction({ - id: 'tx-sale-1', + id: txId, state: 'state/preauthorized', booking: createBooking( 'booking1', @@ -29,6 +30,7 @@ describe('SalePage', () => { currentUser: createCurrentUser('provider1'), onAcceptSale: () => {}, onRejectSale: () => {}, + params: { id: txId }, transaction, tab: 'details', intl: fakeIntl,