From b3cd44d8203337c0d0f2840df607bac054d22e61 Mon Sep 17 00:00:00 2001 From: gutchenzo Date: Fri, 14 Feb 2025 12:15:49 -0300 Subject: [PATCH 01/13] feat: add reviews count to ProductTitle component --- .../molecules/ProductTitle/ProductTitle.tsx | 31 ++++++++++- packages/core/cms/faststore/sections.json | 16 ++++++ .../ProductDetails/ProductDetails.tsx | 12 ++++- .../molecules/ProductTitle/styles.scss | 51 ++++++++++++++----- 4 files changed, 94 insertions(+), 16 deletions(-) diff --git a/packages/components/src/molecules/ProductTitle/ProductTitle.tsx b/packages/components/src/molecules/ProductTitle/ProductTitle.tsx index f6c46c4614..a655026f67 100644 --- a/packages/components/src/molecules/ProductTitle/ProductTitle.tsx +++ b/packages/components/src/molecules/ProductTitle/ProductTitle.tsx @@ -29,6 +29,22 @@ export interface ProductTitleProps * The current value of the rating, a number from 0 to 5. */ ratingValue?: number + /** + * The amount of reviews for the product. + */ + reviewsCount?: number + /** + * The ID of the reviews section to link to. + */ + reviewsSectionId?: string + /** + * Default text for "No reviews yet". + */ + noReviewsText?: string + /** + * Default text for "X Reviews". + */ + reviewsCountText?: string } const ProductTitle = forwardRef( @@ -40,6 +56,10 @@ const ProductTitle = forwardRef( refNumber, testId = 'fs-product-title', ratingValue, + reviewsCount, + reviewsSectionId, + noReviewsText = 'No reviews yet', + reviewsCountText = 'Reviews', ...otherProps }, ref @@ -58,7 +78,16 @@ const ProductTitle = forwardRef( {(refNumber || ratingValue !== undefined) && (
- {ratingValue !== undefined && } +
+ {ratingValue !== undefined && } + {reviewsCount !== undefined && ( + + {reviewsCount > 0 + ? `(${reviewsCount} ${reviewsCountText})` + : `(${noReviewsText})`} + + )} +
{refNumber && ( <> {refTag} {refNumber} diff --git a/packages/core/cms/faststore/sections.json b/packages/core/cms/faststore/sections.json index 9da106bd52..e23b3b989b 100644 --- a/packages/core/cms/faststore/sections.json +++ b/packages/core/cms/faststore/sections.json @@ -1507,6 +1507,22 @@ "title": "Show Reference Number?", "type": "boolean", "default": false + }, + "rating": { + "title": "Rating", + "type": "object", + "properties": { + "noReviewsLabel": { + "title": "No reviews label", + "type": "string", + "default": "No reviews yet" + }, + "reviewsCountLabel": { + "title": "Reviews Count Label", + "type": "string", + "default": "reviews" + } + } } } }, diff --git a/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx b/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx index 259f1a6c29..5b7fcc9a8b 100644 --- a/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx +++ b/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx @@ -35,6 +35,10 @@ export interface ProductDetailsProps { size: 'big' | 'small' showDiscountBadge: boolean } + rating: { + noReviewsLabel: string + reviewsCountLabel: string + } } buyButton: { title: string @@ -88,6 +92,7 @@ function ProductDetails({ productTitle: { refNumber: showRefNumber, discountBadge: { showDiscountBadge, size: discountBadgeSize }, + rating: { noReviewsLabel, reviewsCountLabel }, }, buyButton: { icon: buyButtonIcon, title: buyButtonTitle }, shippingSimulator: { @@ -222,7 +227,12 @@ function ProductDetails({ /> ) } - refNumber={showRefNumber && productId} + // refNumber={showRefNumber && productId} + refNumber={productId} + reviewsCount={10} + reviewsSectionId="reviews-and-ratings" + noReviewsText={noReviewsLabel} + reviewsCountText={reviewsCountLabel} /> *:first-child { + + *:first-child { font-size: var(--fs-product-title-text-size); font-weight: var(--fs-product-title-text-weight); line-height: var(--fs-product-title-line-height); } - [data-fs-badge] { white-space: nowrap; } + [data-fs-badge] { + white-space: nowrap; + } @include media(">=tablet", " Date: Thu, 30 Jan 2025 14:12:46 -0300 Subject: [PATCH 02/13] feat(ProductDetails): update ProductTitle props with apiConfig and rating values --- .../sections/ProductDetails/ProductDetails.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx b/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx index 5b7fcc9a8b..7d6b6d3493 100644 --- a/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx +++ b/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx @@ -204,9 +204,6 @@ function ProductDetails({ // Maybe now it's worth to make title always a h1 and receive only the name, as it would be easier for users to override. title={

{name}

} {...ProductTitle.props} - ratingValue={ - apiConfig.reviewsAndRatings ? rating.average : undefined - } label={ showDiscountBadge && ( ) } - // refNumber={showRefNumber && productId} - refNumber={productId} - reviewsCount={10} + refNumber={showRefNumber && productId} + ratingValue={ + apiConfig.reviewsAndRatings ? rating.average : undefined + } + reviewsCount={ + apiConfig.reviewsAndRatings ? rating.totalCount : undefined + } reviewsSectionId="reviews-and-ratings" noReviewsText={noReviewsLabel} reviewsCountText={reviewsCountLabel} From 5999074dbf0a3cf73ad30b1c1bf6460f4c7cc550 Mon Sep 17 00:00:00 2001 From: Artur Santiago Date: Thu, 30 Jan 2025 14:15:27 -0300 Subject: [PATCH 03/13] feat(ProductTitle): change default value of reviewsCountText --- .../components/src/molecules/ProductTitle/ProductTitle.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/components/src/molecules/ProductTitle/ProductTitle.tsx b/packages/components/src/molecules/ProductTitle/ProductTitle.tsx index a655026f67..716361e722 100644 --- a/packages/components/src/molecules/ProductTitle/ProductTitle.tsx +++ b/packages/components/src/molecules/ProductTitle/ProductTitle.tsx @@ -38,11 +38,11 @@ export interface ProductTitleProps */ reviewsSectionId?: string /** - * Default text for "No reviews yet". + * @default "No reviews yet". */ noReviewsText?: string /** - * Default text for "X Reviews". + * @default "X reviews". */ reviewsCountText?: string } @@ -59,7 +59,7 @@ const ProductTitle = forwardRef( reviewsCount, reviewsSectionId, noReviewsText = 'No reviews yet', - reviewsCountText = 'Reviews', + reviewsCountText = 'reviews', ...otherProps }, ref From a0d9a0a803220124aff3b62b7ce2f8df87f978e4 Mon Sep 17 00:00:00 2001 From: Artur Santiago Date: Thu, 20 Feb 2025 10:25:04 -0300 Subject: [PATCH 04/13] docs(ProductTitle): enhance props comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: LarĂ­cia Mota --- packages/components/src/molecules/ProductTitle/ProductTitle.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/components/src/molecules/ProductTitle/ProductTitle.tsx b/packages/components/src/molecules/ProductTitle/ProductTitle.tsx index 716361e722..664a84471a 100644 --- a/packages/components/src/molecules/ProductTitle/ProductTitle.tsx +++ b/packages/components/src/molecules/ProductTitle/ProductTitle.tsx @@ -38,6 +38,7 @@ export interface ProductTitleProps */ reviewsSectionId?: string /** + * Text to display when there aren't reviews. * @default "No reviews yet". */ noReviewsText?: string From 0755806e4ea779757842aa08f1b20ee54dffc589 Mon Sep 17 00:00:00 2001 From: Artur Santiago Date: Thu, 20 Feb 2025 10:32:10 -0300 Subject: [PATCH 05/13] style(ProductTitle): adding space to increase readability Co-authored-by: Fanny Chien --- packages/components/src/molecules/ProductTitle/ProductTitle.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/components/src/molecules/ProductTitle/ProductTitle.tsx b/packages/components/src/molecules/ProductTitle/ProductTitle.tsx index 664a84471a..f9f6ee8190 100644 --- a/packages/components/src/molecules/ProductTitle/ProductTitle.tsx +++ b/packages/components/src/molecules/ProductTitle/ProductTitle.tsx @@ -81,6 +81,7 @@ const ProductTitle = forwardRef(
{ratingValue !== undefined && } + {reviewsCount !== undefined && ( {reviewsCount > 0 From 5d86935eff01f2d322ec75ea60d4664663ee8907 Mon Sep 17 00:00:00 2001 From: Artur Santiago Date: Thu, 20 Feb 2025 10:32:33 -0300 Subject: [PATCH 06/13] style(ProductTitle): adding space to increase readability Co-authored-by: Fanny Chien --- .../ui/src/components/molecules/ProductTitle/styles.scss | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/components/molecules/ProductTitle/styles.scss b/packages/ui/src/components/molecules/ProductTitle/styles.scss index 0f51abf221..eba887778a 100644 --- a/packages/ui/src/components/molecules/ProductTitle/styles.scss +++ b/packages/ui/src/components/molecules/ProductTitle/styles.scss @@ -10,9 +10,10 @@ --fs-product-title-column-gap: var(--fs-spacing-2); --fs-product-title-row-gap: var(--fs-spacing-3); - --fs-product-title-addendum-color: var(--fs-color-text-light); - --fs-product-title-addendum-size: var(--fs-text-size-1); - --fs-product-title-addendum-line-height: 1.7; + // Addendum + --fs-product-title-addendum-color : var(--fs-color-text-light); + --fs-product-title-addendum-size : var(--fs-text-size-1); + --fs-product-title-addendum-line-height : 1.7; --fs-product-title-reviews-size: var(--fs-text-size-1); --fs-product-title-reviews-line-height: 1.42; From 9820a61ad81926c0633ce174ef2e540c3c69b92d Mon Sep 17 00:00:00 2001 From: Artur Santiago Date: Thu, 20 Feb 2025 10:32:44 -0300 Subject: [PATCH 07/13] style(ProductTitle): adding space to increase readability Co-authored-by: Fanny Chien --- .../ui/src/components/molecules/ProductTitle/styles.scss | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/components/molecules/ProductTitle/styles.scss b/packages/ui/src/components/molecules/ProductTitle/styles.scss index eba887778a..b0ddbfda08 100644 --- a/packages/ui/src/components/molecules/ProductTitle/styles.scss +++ b/packages/ui/src/components/molecules/ProductTitle/styles.scss @@ -15,9 +15,10 @@ --fs-product-title-addendum-size : var(--fs-text-size-1); --fs-product-title-addendum-line-height : 1.7; - --fs-product-title-reviews-size: var(--fs-text-size-1); - --fs-product-title-reviews-line-height: 1.42; - --fs-product-title-reviews-color: var(--fs-color-text-light); + // Reviews + --fs-product-title-reviews-color : var(--fs-color-text-light); + --fs-product-title-reviews-size : var(--fs-text-size-1); + --fs-product-title-reviews-line-height : 1.42; // -------------------------------------------------------- // Structural Styles From dc897c596699679e8905ce7b1ade5d7c597180f1 Mon Sep 17 00:00:00 2001 From: Artur Santiago Date: Thu, 20 Feb 2025 10:32:53 -0300 Subject: [PATCH 08/13] style(ProductTitle): adding space to increase readability Co-authored-by: Fanny Chien --- .../src/components/molecules/ProductTitle/styles.scss | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/ui/src/components/molecules/ProductTitle/styles.scss b/packages/ui/src/components/molecules/ProductTitle/styles.scss index b0ddbfda08..3e3877edef 100644 --- a/packages/ui/src/components/molecules/ProductTitle/styles.scss +++ b/packages/ui/src/components/molecules/ProductTitle/styles.scss @@ -4,11 +4,11 @@ // -------------------------------------------------------- // Default properties - --fs-product-title-text-size: var(--fs-text-size-title-product); - --fs-product-title-text-weight: var(--fs-text-weight-regular); - --fs-product-title-line-height: 1.12; - --fs-product-title-column-gap: var(--fs-spacing-2); - --fs-product-title-row-gap: var(--fs-spacing-3); + --fs-product-title-text-size : var(--fs-text-size-title-product); + --fs-product-title-text-weight : var(--fs-text-weight-regular); + --fs-product-title-line-height : 1.12; + --fs-product-title-column-gap : var(--fs-spacing-2); + --fs-product-title-row-gap : var(--fs-spacing-3); // Addendum --fs-product-title-addendum-color : var(--fs-color-text-light); From cea383ad8343c3d9834f9f4c44557bbec273b856 Mon Sep 17 00:00:00 2001 From: Artur Santiago Date: Thu, 20 Feb 2025 10:41:18 -0300 Subject: [PATCH 09/13] feat(ProductTitle): add support for singular and plural review count --- .../molecules/ProductTitle/ProductTitle.tsx | 23 +++++++++++++------ packages/core/cms/faststore/sections.json | 9 ++++++-- .../ProductDetails/ProductDetails.tsx | 8 ++++--- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/packages/components/src/molecules/ProductTitle/ProductTitle.tsx b/packages/components/src/molecules/ProductTitle/ProductTitle.tsx index f9f6ee8190..5c81c2987f 100644 --- a/packages/components/src/molecules/ProductTitle/ProductTitle.tsx +++ b/packages/components/src/molecules/ProductTitle/ProductTitle.tsx @@ -43,9 +43,15 @@ export interface ProductTitleProps */ noReviewsText?: string /** - * @default "X reviews". + * Text to display when there is only one review. + * @default "review". */ - reviewsCountText?: string + singleReviewText?: string + /** + * Text to display when there are multiple reviews. + * @default "reviews". + */ + multipleReviewsText?: string } const ProductTitle = forwardRef( @@ -60,7 +66,8 @@ const ProductTitle = forwardRef( reviewsCount, reviewsSectionId, noReviewsText = 'No reviews yet', - reviewsCountText = 'reviews', + singleReviewText = 'review', + multipleReviewsText = 'reviews', ...otherProps }, ref @@ -81,12 +88,14 @@ const ProductTitle = forwardRef(
diff --git a/packages/core/cms/faststore/sections.json b/packages/core/cms/faststore/sections.json index e23b3b989b..b47689ac57 100644 --- a/packages/core/cms/faststore/sections.json +++ b/packages/core/cms/faststore/sections.json @@ -1517,10 +1517,15 @@ "type": "string", "default": "No reviews yet" }, - "reviewsCountLabel": { - "title": "Reviews Count Label", + "multipleReviewsText": { + "title": "Multiple reviews text", "type": "string", "default": "reviews" + }, + "singleReviewText": { + "title": "Single review text", + "type": "string", + "default": "review" } } } diff --git a/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx b/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx index 7d6b6d3493..b3e206bd63 100644 --- a/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx +++ b/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx @@ -37,7 +37,8 @@ export interface ProductDetailsProps { } rating: { noReviewsLabel: string - reviewsCountLabel: string + singleReviewText: string + multipleReviewsText: string } } buyButton: { @@ -92,7 +93,7 @@ function ProductDetails({ productTitle: { refNumber: showRefNumber, discountBadge: { showDiscountBadge, size: discountBadgeSize }, - rating: { noReviewsLabel, reviewsCountLabel }, + rating: { noReviewsLabel, multipleReviewsText, singleReviewText }, }, buyButton: { icon: buyButtonIcon, title: buyButtonTitle }, shippingSimulator: { @@ -233,7 +234,8 @@ function ProductDetails({ } reviewsSectionId="reviews-and-ratings" noReviewsText={noReviewsLabel} - reviewsCountText={reviewsCountLabel} + multipleReviewsText={multipleReviewsText} + singleReviewText={singleReviewText} /> Date: Thu, 20 Feb 2025 10:47:11 -0300 Subject: [PATCH 10/13] feat(ProductTitle): grouping reviews props in one object --- .../molecules/ProductTitle/ProductTitle.tsx | 66 ++++++++++--------- packages/core/cms/faststore/sections.json | 4 +- .../ProductDetails/ProductDetails.tsx | 25 +++---- 3 files changed, 50 insertions(+), 45 deletions(-) diff --git a/packages/components/src/molecules/ProductTitle/ProductTitle.tsx b/packages/components/src/molecules/ProductTitle/ProductTitle.tsx index 5c81c2987f..3efe1b3362 100644 --- a/packages/components/src/molecules/ProductTitle/ProductTitle.tsx +++ b/packages/components/src/molecules/ProductTitle/ProductTitle.tsx @@ -26,32 +26,33 @@ export interface ProductTitleProps */ refNumber?: string /** - * The current value of the rating, a number from 0 to 5. + * Object containing the rating value and reviews count */ - ratingValue?: number - /** - * The amount of reviews for the product. - */ - reviewsCount?: number - /** - * The ID of the reviews section to link to. - */ - reviewsSectionId?: string - /** - * Text to display when there aren't reviews. - * @default "No reviews yet". - */ - noReviewsText?: string - /** - * Text to display when there is only one review. - * @default "review". - */ - singleReviewText?: string - /** - * Text to display when there are multiple reviews. - * @default "reviews". - */ - multipleReviewsText?: string + reviewsAndRating?: { + /** + * The current value of the rating, a number from 0 to 5. + */ + ratingValue?: number + /** + * The amount of reviews for the product. + */ + reviewsCount?: number + /** + * Text to display when there aren't reviews. + * @default "No reviews yet". + */ + noReviewsText?: string + /** + * Text to display when there is only one review. + * @default "review". + */ + singleReviewText?: string + /** + * Text to display when there are multiple reviews. + * @default "reviews". + */ + multipleReviewsText?: string + } } const ProductTitle = forwardRef( @@ -62,16 +63,19 @@ const ProductTitle = forwardRef( refTag = 'Ref.: ', refNumber, testId = 'fs-product-title', + reviewsAndRating, + ...otherProps + }, + ref + ) { + const { ratingValue, reviewsCount, - reviewsSectionId, noReviewsText = 'No reviews yet', singleReviewText = 'review', multipleReviewsText = 'reviews', - ...otherProps - }, - ref - ) { + } = reviewsAndRating || {} + return (
( {ratingValue !== undefined && } {reviewsCount !== undefined && ( - + {reviewsCount === 0 && `(${noReviewsText})`} {reviewsCount === 1 && `(${reviewsCount} ${singleReviewText})`} diff --git a/packages/core/cms/faststore/sections.json b/packages/core/cms/faststore/sections.json index b47689ac57..c82caca8c7 100644 --- a/packages/core/cms/faststore/sections.json +++ b/packages/core/cms/faststore/sections.json @@ -1512,8 +1512,8 @@ "title": "Rating", "type": "object", "properties": { - "noReviewsLabel": { - "title": "No reviews label", + "noReviewsText": { + "title": "No reviews text", "type": "string", "default": "No reviews yet" }, diff --git a/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx b/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx index b3e206bd63..bb6fc3aafd 100644 --- a/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx +++ b/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx @@ -36,7 +36,7 @@ export interface ProductDetailsProps { showDiscountBadge: boolean } rating: { - noReviewsLabel: string + noReviewsText: string singleReviewText: string multipleReviewsText: string } @@ -93,7 +93,7 @@ function ProductDetails({ productTitle: { refNumber: showRefNumber, discountBadge: { showDiscountBadge, size: discountBadgeSize }, - rating: { noReviewsLabel, multipleReviewsText, singleReviewText }, + rating: { noReviewsText, multipleReviewsText, singleReviewText }, }, buyButton: { icon: buyButtonIcon, title: buyButtonTitle }, shippingSimulator: { @@ -226,16 +226,17 @@ function ProductDetails({ ) } refNumber={showRefNumber && productId} - ratingValue={ - apiConfig.reviewsAndRatings ? rating.average : undefined - } - reviewsCount={ - apiConfig.reviewsAndRatings ? rating.totalCount : undefined - } - reviewsSectionId="reviews-and-ratings" - noReviewsText={noReviewsLabel} - multipleReviewsText={multipleReviewsText} - singleReviewText={singleReviewText} + reviewsAndRating={{ + ratingValue: apiConfig.reviewsAndRatings + ? rating.average + : undefined, + reviewsCount: apiConfig.reviewsAndRatings + ? rating.totalCount + : undefined, + noReviewsText, + multipleReviewsText, + singleReviewText, + }} />
Date: Thu, 20 Feb 2025 10:58:32 -0300 Subject: [PATCH 11/13] style(ProductTitle): remove unnecessary comment Co-authored-by: Fanny Chien --- packages/ui/src/components/molecules/ProductTitle/styles.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/ui/src/components/molecules/ProductTitle/styles.scss b/packages/ui/src/components/molecules/ProductTitle/styles.scss index 3e3877edef..2b8f1f24fa 100644 --- a/packages/ui/src/components/molecules/ProductTitle/styles.scss +++ b/packages/ui/src/components/molecules/ProductTitle/styles.scss @@ -32,7 +32,6 @@ justify-content: space-between; max-width: 42ch; - // Title prop *:first-child { font-size: var(--fs-product-title-text-size); From 000f804b84d5a852d1beed7569dd2463a2289472 Mon Sep 17 00:00:00 2001 From: Artur Santiago Date: Thu, 20 Feb 2025 11:00:46 -0300 Subject: [PATCH 12/13] style(ProductTitle): run stylelint:fix --- packages/ui/src/components/molecules/ProductTitle/styles.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/ui/src/components/molecules/ProductTitle/styles.scss b/packages/ui/src/components/molecules/ProductTitle/styles.scss index 2b8f1f24fa..c85a130d97 100644 --- a/packages/ui/src/components/molecules/ProductTitle/styles.scss +++ b/packages/ui/src/components/molecules/ProductTitle/styles.scss @@ -32,7 +32,6 @@ justify-content: space-between; max-width: 42ch; - *:first-child { font-size: var(--fs-product-title-text-size); font-weight: var(--fs-product-title-text-weight); From c4411f6f2d4dee6557ed3d3b7533b1f8a9d5f8be Mon Sep 17 00:00:00 2001 From: Artur Santiago Date: Thu, 20 Feb 2025 12:07:24 -0300 Subject: [PATCH 13/13] feat(ProductTitle): only send when the feature is activated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: LarĂ­cia Mota --- .../ProductDetails/ProductDetails.tsx | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx b/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx index bb6fc3aafd..01bc82bdc5 100644 --- a/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx +++ b/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx @@ -226,17 +226,15 @@ function ProductDetails({ ) } refNumber={showRefNumber && productId} - reviewsAndRating={{ - ratingValue: apiConfig.reviewsAndRatings - ? rating.average - : undefined, - reviewsCount: apiConfig.reviewsAndRatings - ? rating.totalCount - : undefined, - noReviewsText, - multipleReviewsText, - singleReviewText, - }} + {...(apiConfig.reviewsAndRatings && { + reviewsAndRating: { + ratingValue: rating.average, + reviewsCount: rating.totalCount, + noReviewsText, + multipleReviewsText, + singleReviewText, + }, + })} />