Skip to content

Commit

Permalink
feat: pass advertisement to ProductCard component
Browse files Browse the repository at this point in the history
  • Loading branch information
pedromtec committed Sep 16, 2024
1 parent 14d8de3 commit ef6c86c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
11 changes: 11 additions & 0 deletions packages/components/src/molecules/ProductCard/ProductCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ export interface ProductCardProps extends HTMLAttributes<HTMLDivElement> {
* testing-library, and jest).
*/
testId?: string

advertisement?: {
adId: string;
campaignId: string;
actionCost: number;
adRequestId: string;
adResponseId: string;
}

}

const ProductCard = forwardRef<HTMLDivElement, ProductCardProps>(
Expand All @@ -29,12 +38,14 @@ const ProductCard = forwardRef<HTMLDivElement, ProductCardProps>(
bordered = false,
outOfStock,
children,
advertisement,
...otherProps
},
ref
) {
return (
<article
data-test={advertisement?.campaignId ?? ''}
ref={ref}
data-fs-product-card={outOfStock ? 'out-of-stock' : ''}
data-fs-product-card-variant={variant}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/faststore.config.default.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
subDomainPrefix: ['www'],
environment: 'vtexcommercestable',
hideUnavailableItems: false,
showSponsored: false,
showSponsored: true,
incrementAddress: true,
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ function ProductCard({
sku,
isVariantOf: { name },
image: [img],
advertisement,
offers: {
lowPrice,
lowPriceWithTaxes,
Expand Down Expand Up @@ -105,13 +106,14 @@ function ProductCard({
: listPriceBase

const hasDiscount = spotPrice <= listPrice

console.log(advertisement)
return (
<UIProductCard
outOfStock={outOfStock}
bordered={bordered}
variant={variant}
data-fs-product-card-sku={sku}
advertisement={advertisement}
{...otherProps}
>
<UIProductCardImage aspectRatio={aspectRatio}>
Expand Down

0 comments on commit ef6c86c

Please sign in to comment.