Skip to content

Commit

Permalink
Merge pull request #164 from vtex-apps/fix/wishlist
Browse files Browse the repository at this point in the history
Added missing interface to handle Wishlist button when using product-summary.shelf
  • Loading branch information
Breno Calazans committed Jun 10, 2019
2 parents fc376e7 + 64009a4 commit e552076
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 2 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [2.25.0] - 2019-06-10

### Added

- Missing interface to handle Wishlist button when using `product-summary.shelf`.

### Fixed

- Add `product-rating-inline` to `product-summary-column`.

## [2.24.2] - 2019-06-04
### Changed
- Updated `vtex.pixel-manager`.
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"vendor": "vtex",
"name": "product-summary",
"version": "2.24.2",
"version": "2.25.0",
"title": "Product Summary",
"description": "Product summary component",
"defaultLocale": "pt-BR",
Expand Down
3 changes: 3 additions & 0 deletions react/ProductSummaryAddToListButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ProductSummaryAddToListButton from './components/ProductSummaryAddToListButton/ProductSummaryAddToListButton'

export default ProductSummaryAddToListButton
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React, { useMemo, useContext } from 'react'
import { ExtensionPoint } from 'vtex.render-runtime'
import { path } from 'ramda'
import ProductSummaryContext from '../ProductSummaryContext'
import productSummary from '../../productSummary.css'

const getSkuId = path(['sku', 'itemId'])
const getProductId = path(['productId'])

// This avoids triggering the link to the product page
const captureClick = e => {
e.preventDefault()
e.stopPropagation()
}

function ProductSummaryAddToListButton({ product }) {
const productContext = useContext(ProductSummaryContext)

const skuId = getSkuId(productContext.product)
const productId = getProductId(productContext.product)

const productProp = useMemo(() => ({
skuId, productId, quantity: 1
}), [skuId, productId])

return (
<div className={`${productSummary.addToListBtn} absolute z-1`} onClick={captureClick}>
<ExtensionPoint id="addon-summary-btn" product={productProp} />
</div>
)
}

export default ProductSummaryAddToListButton
11 changes: 10 additions & 1 deletion store/interfaces.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"product-summary-name",
"product-summary-price",
"product-summary-space",
"product-summary-add-to-list-button",
"product-rating-inline"
],
"component": "ProductSummaryCustom",
Expand All @@ -29,7 +30,9 @@
"product-summary-image",
"product-summary-name",
"product-summary-price",
"product-summary-space"
"product-summary-space",
"product-summary-add-to-list-button",
"product-rating-inline"
],
"component": "Column",
"composition": "children"
Expand Down Expand Up @@ -107,6 +110,12 @@
}
}
},
"product-summary-add-to-list-button": {
"component": "ProductSummaryAddToListButton",
"allowed": [
"addon-summary-btn"
]
},
"addon-summary-btn": {
"component": "*"
}
Expand Down

0 comments on commit e552076

Please sign in to comment.