Skip to content

Commit

Permalink
Merge 751f07d into 1bbbe78
Browse files Browse the repository at this point in the history
  • Loading branch information
italo-batista committed May 10, 2019
2 parents 1bbbe78 + 751f07d commit b8da72d
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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]
### Added
- Send productClick events to Pixel Manager.

## [1.13.0] - 2019-05-07

Expand Down
5 changes: 3 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"vtex.product-summary": "2.x",
"vtex.styleguide": "9.x",
"vtex.slider": "0.x",
"vtex.store-icons": "0.x"
"vtex.store-icons": "0.x",
"vtex.pixel-manager": "0.x"
}
}
}
4 changes: 2 additions & 2 deletions react/ProductList.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import GapPaddingTypes, {
getGapPaddingValues,
} from './paddingEnum'
import ShelfContent from './ShelfContent'
import ShelfItem from './ShelfItem'
import { shelfItemPropTypes } from './propTypes'

import shelf from './shelf.css'

Expand Down Expand Up @@ -167,7 +167,7 @@ ProductList.propTypes = {
/** Loading status */
loading: PropTypes.bool,
/** Graphql data response. */
products: PropTypes.arrayOf(ShelfItem.propTypes.item),
products: PropTypes.arrayOf(shelfItemPropTypes.item),
/** Verifies if is a mobile device. */
isMobile: PropTypes.bool,
...productListSchemaPropTypes,
Expand Down
8 changes: 4 additions & 4 deletions react/RelatedProducts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { Component } from 'react'

import ProductList from './ProductList'
import { productListSchemaPropTypes } from './propTypes'
import ShelfItem from './ShelfItem'
import { shelfItemPropTypes } from './propTypes'
import shelf from './shelf.css'

/**
Expand All @@ -21,11 +21,11 @@ export default class RelatedProducts extends Component {
/** Recommendations property */
recommendations: PropTypes.shape({
/** View recommendations (who saw this product, also saw...) */
view: PropTypes.arrayOf(ShelfItem.propTypes.item),
view: PropTypes.arrayOf(shelfItemPropTypes.item),
/** Buy recommendations (who bought this product, also bought...) */
buy: PropTypes.arrayOf(ShelfItem.propTypes.item),
buy: PropTypes.arrayOf(shelfItemPropTypes.item),
/** Similar products */
similars: PropTypes.arrayOf(ShelfItem.propTypes.item),
similars: PropTypes.arrayOf(shelfItemPropTypes.item),
}),
}),
}),
Expand Down
3 changes: 2 additions & 1 deletion react/ShelfContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { getGapPaddingValues } from './paddingEnum'
import ScrollTypes from './ScrollTypes'
import ShelfItem from './ShelfItem'
import { shelfItemPropTypes } from './propTypes'

import shelf from './shelf.css'

Expand Down Expand Up @@ -158,7 +159,7 @@ ShelfContent.defaultProps = {

ShelfContent.propTypes = {
/** List of products */
products: PropTypes.arrayOf(ShelfItem.propTypes.item),
products: PropTypes.arrayOf(shelfItemPropTypes.item),
/** Max Items per page */
itemsPerPage: PropTypes.number.isRequired,
/** Max items in shelf */
Expand Down
13 changes: 12 additions & 1 deletion react/ShelfItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from 'react'
import { path, assocPath } from 'ramda'

import { ExtensionPoint } from 'vtex.render-runtime'
import { Pixel } from 'vtex.pixel-manager/PixelContext'

import { shelfItemPropTypes } from './propTypes'
import { changeImageUrlSize, toHttps } from './utils/urlHelpers'
Expand All @@ -10,9 +11,16 @@ import { changeImageUrlSize, toHttps } from './utils/urlHelpers'
* ShelfItem Component. Normalizes the item received in the props
* to adapt to the extension point prop.
*/
export default class ShelfItem extends Component {
class ShelfItem extends Component {
static propTypes = shelfItemPropTypes

sendProductClickEvent = product => {
this.props.push({
event: 'productClick',
product: product,
})
}

findAvailableProduct = item =>
item.sellers.find(
({ commertialOffer = {} }) => commertialOffer.AvailableQuantity > 0
Expand Down Expand Up @@ -47,8 +55,11 @@ export default class ShelfItem extends Component {
<ExtensionPoint
id="product-summary"
product={this.normalizeProduct(item)}
actionOnClick={() => this.sendProductClickEvent(item)}
{...newSummary}
/>
)
}
}

export default Pixel(ShelfItem)
9 changes: 9 additions & 0 deletions react/__mocks__/vtex.pixel-manager/PixelContext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react'

export function Pixel(Comp) {
return class extends React.Component {
render() {
return <Comp {...this.props} push={() => {}} subscribe={() => {}} />
}
}
}

0 comments on commit b8da72d

Please sign in to comment.