-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #164 from vtex-apps/fix/wishlist
Added missing interface to handle Wishlist button when using product-summary.shelf
- Loading branch information
Showing
5 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import ProductSummaryAddToListButton from './components/ProductSummaryAddToListButton/ProductSummaryAddToListButton' | ||
|
||
export default ProductSummaryAddToListButton |
33 changes: 33 additions & 0 deletions
33
react/components/ProductSummaryAddToListButton/ProductSummaryAddToListButton.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters