Skip to content

Commit

Permalink
Streamline sale buttons visibility logic
Browse files Browse the repository at this point in the history
  • Loading branch information
lyyder committed Dec 20, 2018
1 parent ad6fc63 commit 1dba153
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions src/components/TransactionPanel/TransactionPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,24 +185,20 @@ export class TransactionPanelComponent extends Component {
currentListing.images && currentListing.images.length > 0 ? currentListing.images[0] : null;

const actionButtonClasses = classNames(css.actionButtons);
const canShowActionButtons = canShowSaleButtons;

let actionButtons = null;
if (canShowSaleButtons) {
actionButtons = (
<SaleActionButtonsMaybe
rootClassName={actionButtonClasses}
canShowButtons={canShowSaleButtons}
transaction={currentTransaction}
acceptInProgress={acceptInProgress}
declineInProgress={declineInProgress}
acceptSaleError={acceptSaleError}
declineSaleError={declineSaleError}
onAcceptSale={onAcceptSale}
onDeclineSale={onDeclineSale}
/>
);
}

const saleButtons = (
<SaleActionButtonsMaybe
rootClassName={actionButtonClasses}
canShowButtons={canShowSaleButtons}
transaction={currentTransaction}
acceptInProgress={acceptInProgress}
declineInProgress={declineInProgress}
acceptSaleError={acceptSaleError}
declineSaleError={declineSaleError}
onAcceptSale={onAcceptSale}
onDeclineSale={onDeclineSale}
/>
);

const sendMessagePlaceholder = intl.formatMessage(
{ id: 'TransactionPanel.sendMessagePlaceholder' },
Expand Down Expand Up @@ -293,8 +289,8 @@ export class TransactionPanelComponent extends Component {
onBlur={this.onSendMessageFormBlur}
onSubmit={this.onMessageSubmit}
/>
{canShowActionButtons ? (
<div className={css.mobileActionButtons}>{actionButtons}</div>
{canShowSaleButtons ? (
<div className={css.mobileActionButtons}>{saleButtons}</div>
) : null}
</div>

Expand Down Expand Up @@ -342,8 +338,8 @@ export class TransactionPanelComponent extends Component {
transactionRole={transactionRole}
/>

{canShowActionButtons ? (
<div className={css.desktopActionButtons}>{actionButtons}</div>
{canShowSaleButtons ? (
<div className={css.desktopActionButtons}>{saleButtons}</div>
) : null}
</div>
</div>
Expand Down

0 comments on commit 1dba153

Please sign in to comment.