From 68f6eaa39144b640a28f1947749c1568ddc81edb Mon Sep 17 00:00:00 2001 From: Hannu Lyytikainen Date: Fri, 7 Dec 2018 15:04:10 +0200 Subject: [PATCH] Show BookingPanel on tx page Show the BookingPanel component on the tx page when the transaction has been started with an enquiry. --- .../TransactionPanel/TransactionPanel.css | 4 ++ .../TransactionPanel.helpers.js | 58 ++++++++++++++++--- .../TransactionPanel/TransactionPanel.js | 53 +++++++---------- 3 files changed, 76 insertions(+), 39 deletions(-) diff --git a/src/components/TransactionPanel/TransactionPanel.css b/src/components/TransactionPanel/TransactionPanel.css index 72f0ae9a..f80a233a 100644 --- a/src/components/TransactionPanel/TransactionPanel.css +++ b/src/components/TransactionPanel/TransactionPanel.css @@ -404,3 +404,7 @@ top: 151px; } } + +.bookingPanel { + margin: 16px 48px 48px 48px; +} diff --git a/src/components/TransactionPanel/TransactionPanel.helpers.js b/src/components/TransactionPanel/TransactionPanel.helpers.js index e74f6814..12381353 100644 --- a/src/components/TransactionPanel/TransactionPanel.helpers.js +++ b/src/components/TransactionPanel/TransactionPanel.helpers.js @@ -18,6 +18,7 @@ import { createSlug, stringify } from '../../util/urlHelpers'; import { ActivityFeed, BookingBreakdown, + BookingPanel, ExternalLink, NamedLink, PrimaryButton, @@ -151,16 +152,57 @@ const createListingLink = (listing, label, searchParams = {}, className = '') => } }; -// Functional component as a helper to build ActionButtons for -// provider when state is preauthorized -export const OrderActionButtonMaybe = props => { - const { className, rootClassName, canShowButtons, listing } = props; +// Functional component as a helper to build detail card headings +export const DetailCardHeadingsMaybe = props => { + const { authorDisplayName, transaction, transactionRole, listing, listingTitle } = props; - const title = ; - const listingLink = createListingLink(listing, title, { book: true }, css.requestToBookButton); - const classes = classNames(rootClassName || css.actionButtons, className); + const isCustomer = transactionRole === 'customer'; + const canShowDetailCardHeadings = isCustomer && !txIsEnquired(transaction); - return canShowButtons ?
{listingLink}
: null; + return canShowDetailCardHeadings ? ( +
+

{listingTitle}

+

+ +

+ +
+ ) : null; +}; + +// Functional component as a helper to build a BookingPanel +export const BookingPanelMaybe = props => { + const { + authorDisplayName, + transaction, + transactionRole, + listing, + listingTitle, + provider, + } = props; + + const isProviderLoaded = !!provider.id; + const isProviderBanned = isProviderLoaded && provider.attributes.banned; + const isCustomer = transactionRole === 'customer'; + const canShowBookingPanel = isCustomer && txIsEnquired(transaction) && !isProviderBanned; + + return canShowBookingPanel ? ( + console.log('submit')} + richTitle={listingTitle} + authorDisplayName={authorDisplayName} + onManageDisableScrolling={() => null} + timeSlots={null} + fetchTimeSlotsError={null} + /> + ) : null; }; // Functional component as a helper to build ActionButtons for diff --git a/src/components/TransactionPanel/TransactionPanel.js b/src/components/TransactionPanel/TransactionPanel.js index c55d291d..945bb864 100644 --- a/src/components/TransactionPanel/TransactionPanel.js +++ b/src/components/TransactionPanel/TransactionPanel.js @@ -1,8 +1,8 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import { injectIntl, intlShape, FormattedMessage } from 'react-intl'; +import { injectIntl, intlShape } from 'react-intl'; import classNames from 'classnames'; -import { txIsEnquired, txIsRequested, propTypes } from '../../util/types'; +import { txIsRequested, propTypes } from '../../util/types'; import { ensureListing, ensureTransaction, ensureUser } from '../../util/data'; import { isMobileSafari } from '../../util/userAgent'; import { AvatarMedium, AvatarLarge, ResponsiveImage, ReviewModal } from '../../components'; @@ -11,9 +11,10 @@ import { SendMessageForm } from '../../forms'; // These are internal components that make this file more readable. import { AddressLinkMaybe, + BookingPanelMaybe, BreakdownMaybe, + DetailCardHeadingsMaybe, FeedSection, - OrderActionButtonMaybe, SaleActionButtonsMaybe, TransactionPageTitle, TransactionPageMessage, @@ -142,9 +143,6 @@ export class TransactionPanelComponent extends Component { const customerLoaded = !!currentCustomer.id; const isCustomerBanned = customerLoaded && currentCustomer.attributes.banned; const canShowSaleButtons = isProvider && txIsRequested(currentTransaction) && !isCustomerBanned; - const isProviderLoaded = !!currentProvider.id; - const isProviderBanned = isProviderLoaded && currentProvider.attributes.banned; - const canShowBookButton = isCustomer && txIsEnquired(currentTransaction) && !isProviderBanned; const bannedUserDisplayName = intl.formatMessage({ id: 'TransactionPanel.bannedUserDisplayName', @@ -168,7 +166,7 @@ export class TransactionPanelComponent extends Component { currentListing.images && currentListing.images.length > 0 ? currentListing.images[0] : null; const actionButtonClasses = classNames(css.actionButtons); - const canShowActionButtons = canShowBookButton || canShowSaleButtons; + const canShowActionButtons = canShowSaleButtons; let actionButtons = null; if (canShowSaleButtons) { @@ -185,14 +183,6 @@ export class TransactionPanelComponent extends Component { onDeclineSale={onDeclineSale} /> ); - } else if (canShowBookButton) { - actionButtons = ( - - ); } const sendMessagePlaceholder = intl.formatMessage( @@ -306,23 +296,24 @@ export class TransactionPanelComponent extends Component { ) : null} - {isCustomer ? ( -
-

{listingTitle}

-

- -

- -
- )} + + + + {canShowActionButtons ? (
{actionButtons}
) : null}