diff --git a/src/components/TransactionPanel/TransactionPanel.js b/src/components/TransactionPanel/TransactionPanel.js index d300d617..7274219d 100644 --- a/src/components/TransactionPanel/TransactionPanel.js +++ b/src/components/TransactionPanel/TransactionPanel.js @@ -1,8 +1,9 @@ import React, { Component } from 'react'; -import PropTypes from 'prop-types'; +import { array, arrayOf, bool, func, number, string } from 'prop-types'; import { injectIntl, intlShape } from 'react-intl'; import classNames from 'classnames'; import { + TRANSITION_REQUEST_PAYMENT_AFTER_ENQUIRY, txIsAccepted, txIsCanceled, txIsDeclined, @@ -182,6 +183,7 @@ export class TransactionPanelComponent extends Component { onSubmitBookingRequest, timeSlots, fetchTimeSlotsError, + nextTransitions, } = this.props; const currentTransaction = ensureTransaction(transaction); @@ -202,9 +204,16 @@ export class TransactionPanelComponent extends Component { const stateDataFn = tx => { if (txIsEnquired(tx)) { + const transitions = Array.isArray(nextTransitions) + ? nextTransitions.map(transition => { + return transition.attributes.name; + }) + : []; + const hasCorrectNextTransition = + transitions.length > 0 && transitions.includes(TRANSITION_REQUEST_PAYMENT_AFTER_ENQUIRY); return { headingState: HEADING_ENQUIRED, - showBookingPanel: isCustomer && !isProviderBanned, + showBookingPanel: isCustomer && !isProviderBanned && hasCorrectNextTransition, }; } else if (txIsPaymentPending(tx)) { return { @@ -456,10 +465,9 @@ TransactionPanelComponent.defaultProps = { sendReviewError: null, timeSlots: null, fetchTimeSlotsError: null, + nextTransitions: null, }; -const { arrayOf, bool, func, number, string } = PropTypes; - TransactionPanelComponent.propTypes = { rootClassName: string, className: string, @@ -483,6 +491,7 @@ TransactionPanelComponent.propTypes = { onSubmitBookingRequest: func.isRequired, timeSlots: arrayOf(propTypes.timeSlot), fetchTimeSlotsError: propTypes.error, + nextTransitions: array, // Sale related props onAcceptSale: func.isRequired, diff --git a/src/containers/TransactionPage/TransactionPage.js b/src/containers/TransactionPage/TransactionPage.js index 15df684c..e5b3bed9 100644 --- a/src/containers/TransactionPage/TransactionPage.js +++ b/src/containers/TransactionPage/TransactionPage.js @@ -74,6 +74,7 @@ export const TransactionPageComponent = props => { onDeclineSale, timeSlots, fetchTimeSlotsError, + processTransitions, callSetInitialValues, onInitializeCardPaymentData, } = props; @@ -232,6 +233,7 @@ export const TransactionPageComponent = props => { declineInProgress={declineInProgress} acceptSaleError={acceptSaleError} declineSaleError={declineSaleError} + nextTransitions={processTransitions} onSubmitBookingRequest={handleSubmitBookingRequest} timeSlots={timeSlots} fetchTimeSlotsError={fetchTimeSlotsError} @@ -334,6 +336,7 @@ const mapStateToProps = state => { sendReviewError, timeSlots, fetchTimeSlotsError, + processTransitions, } = state.TransactionPage; const { currentUser } = state.user; @@ -361,6 +364,7 @@ const mapStateToProps = state => { sendReviewError, timeSlots, fetchTimeSlotsError, + processTransitions, }; };