Skip to content

Commit

Permalink
Validation added at shouldAddToCart prop.
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosewbank-acct committed Apr 17, 2020
1 parent f2735d2 commit e4347ec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Validation added at `shouldAddToCart` prop.

## [2.53.2] - 2020-04-16
### Fixed
Expand Down
25 changes: 10 additions & 15 deletions react/components/ProductSummaryBuyButton/ProductSummaryBuyButton.js
Expand Up @@ -49,18 +49,11 @@ const ProductSummaryBuyButton = ({
mobile
)

const buyButtonClasses = classnames(
handles.buyButton,
'center mw-100',
{
[productSummary.isHidden]: !hoverBuyButton,
}
)
const buyButtonClasses = classnames(handles.buyButton, 'center mw-100', {
[productSummary.isHidden]: !hoverBuyButton,
})

const containerClass = classnames(
handles.buyButtonContainer,
'pv3 w-100 db'
)
const containerClass = classnames(handles.buyButtonContainer, 'pv3 w-100 db')

const selectedSeller = path(['seller'], selectedItem)
const isAvailable =
Expand All @@ -77,9 +70,11 @@ const ProductSummaryBuyButton = ({
const { items = [] } = product
// if the item is not available the behavior is just show the disabled BuyButton,
// but you still can go to the product page clicking in the summary
const shouldBeALink =
(items.length !== 1 || buyButtonBehavior !== DEFAULT_BUTTON_BEHAVIOR) &&
isAvailable

const shouldAddToCart =
((items.length !== 1 || buyButtonBehavior !== DEFAULT_BUTTON_BEHAVIOR) &&
isAvailable) ||
selectedItem

return (
showBuyButton && (
Expand All @@ -93,7 +88,7 @@ const ProductSummaryBuyButton = ({
available={isAvailable}
isOneClickBuy={isOneClickBuy}
customToastURL={customToastURL}
shouldAddToCart={!shouldBeALink}
shouldAddToCart={shouldAddToCart}
>
<IOMessage id={buyButtonText} />
</BuyButton>
Expand Down

0 comments on commit e4347ec

Please sign in to comment.