Skip to content

Commit

Permalink
feat: add groupBy prop in recommendation shelf
Browse files Browse the repository at this point in the history
  • Loading branch information
iago1501 committed Mar 11, 2024
1 parent 164a8f1 commit 2c6bde8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
19 changes: 18 additions & 1 deletion react/RelatedProducts.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const fixRecommendation = recommendation => {
const RelatedProducts = ({
productQuery,
productList,
groupBy,

Check warning on line 35 in react/RelatedProducts.js

View workflow job for this annotation

GitHub Actions / Lint

'groupBy' is missing in props validation
recommendation: cmsRecommendation,

Check warning on line 36 in react/RelatedProducts.js

View workflow job for this annotation

GitHub Actions / Lint

'recommendation' is missing in props validation
trackingId: rawTrackingId,
hideOutOfStockItems,
Expand Down Expand Up @@ -64,8 +65,9 @@ const RelatedProducts = ({
return {
identifier: { field: 'id', value: productId },
type: recommendation,
groupBy

Check failure on line 68 in react/RelatedProducts.js

View workflow job for this annotation

GitHub Actions / Lint

Insert `,`
}
}, [productId, recommendation])
}, [productId, recommendation, groupBy])

if (!productId) {
return null
Expand Down Expand Up @@ -128,6 +130,7 @@ RelatedProducts.defaultProps = {
...ProductList.defaultProps,
titleText: 'Related Products',
},
groupBy: 'PRODUCT',
hideOutOfStockItems: false,
}

Expand Down Expand Up @@ -158,6 +161,20 @@ RelatedProducts.schema = {
'admin/editor.relatedProducts.suggestions',
],
},
groupBy:{

Check failure on line 164 in react/RelatedProducts.js

View workflow job for this annotation

GitHub Actions / Lint

Insert `·`
title: 'admin/editor.relatedProducts.groupBy.title',
description: 'admin/editor.relatedProducts.groupBy.description',
type: 'string',
default: RelatedProducts.defaultProps.groupBy,
enum: [

Check failure on line 169 in react/RelatedProducts.js

View workflow job for this annotation

GitHub Actions / Lint

Replace `⏎········'PRODUCT',⏎········'NONE',⏎······` with `'PRODUCT',·'NONE'`
'PRODUCT',
'NONE',
],
enumNames: [
'admin/editor.relatedProducts.groupBy.product',
'admin/editor.relatedProducts.groupBy.none'

Check failure on line 175 in react/RelatedProducts.js

View workflow job for this annotation

GitHub Actions / Lint

Insert `,`
],
},
productList: ProductList.schema,
hideOutOfStockItems: {
title: 'admin/editor.shelf.hideOutOfStockItems',
Expand Down
3 changes: 2 additions & 1 deletion react/queries/productRecommendations.gql
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
query ProductRecommendations(
$identifier: ProductUniqueIdentifier
$type: CrossSelingInputEnum
$groupBy: CrossSelingGroupByEnum
) {
productRecommendations(identifier: $identifier, type: $type)
productRecommendations(identifier: $identifier, type: $type, groupBy: $groupBy)
@context(provider: "vtex.search-graphql") {
cacheId
productId
Expand Down

0 comments on commit 2c6bde8

Please sign in to comment.