Skip to content

Commit cc7a3f7

Browse files
feat(promotions): PROMO-1574 resolve moreOffers label inline in productCard
1 parent f71a81f commit cc7a3f7

11 files changed

Lines changed: 4 additions & 31 deletions

File tree

core/app/[locale]/(default)/(faceted)/brand/[slug]/page.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ export default async function Brand(props: Props) {
9696
setRequestLocale(locale);
9797

9898
const t = await getTranslations('Faceted');
99-
const tProductCard = await getTranslations('Components.ProductCard');
10099

101100
const brandId = Number(slug);
102101

@@ -224,7 +223,6 @@ export default async function Brand(props: Props) {
224223
filtersPanelTitle={t('FacetedSearch.filters')}
225224
maxCompareLimitMessage={t('Compare.maxCompareLimit')}
226225
maxItems={MAX_COMPARE_LIMIT}
227-
moreOffersLabel={(count) => tProductCard('moreOffers', { count })}
228226
paginationInfo={streamablePagination}
229227
products={streamableProducts}
230228
rangeFilterApplyLabel={t('FacetedSearch.Range.apply')}

core/app/[locale]/(default)/(faceted)/category/[slug]/page.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ export default async function Category(props: Props) {
103103
setRequestLocale(locale);
104104

105105
const t = await getTranslations('Faceted');
106-
const tProductCard = await getTranslations('Components.ProductCard');
107106

108107
const categoryId = Number(slug);
109108

@@ -270,7 +269,6 @@ export default async function Category(props: Props) {
270269
filtersPanelTitle={t('FacetedSearch.filters')}
271270
maxCompareLimitMessage={t('Compare.maxCompareLimit')}
272271
maxItems={MAX_COMPARE_LIMIT}
273-
moreOffersLabel={(count) => tProductCard('moreOffers', { count })}
274272
paginationInfo={streamablePagination}
275273
products={streamableProducts}
276274
rangeFilterApplyLabel={t('FacetedSearch.Range.apply')}

core/app/[locale]/(default)/(faceted)/search/page.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ export default async function Search(props: Props) {
7575
setRequestLocale(locale);
7676

7777
const t = await getTranslations('Faceted');
78-
const tProductCard = await getTranslations('Components.ProductCard');
7978

8079
const { settings } = await getSearchPageData();
8180

@@ -256,7 +255,6 @@ export default async function Search(props: Props) {
256255
filtersPanelTitle={t('FacetedSearch.filters')}
257256
maxCompareLimitMessage={t('Compare.maxCompareLimit')}
258257
maxItems={MAX_COMPARE_LIMIT}
259-
moreOffersLabel={(count) => tProductCard('moreOffers', { count })}
260258
paginationInfo={streamablePagination}
261259
products={streamableProducts}
262260
rangeFilterApplyLabel={t('FacetedSearch.Range.apply')}

core/app/[locale]/(default)/page.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,8 @@ export default async function Home({ params }: Props) {
3232
setRequestLocale(locale);
3333

3434
const t = await getTranslations('Home');
35-
const tProductCard = await getTranslations('Components.ProductCard');
3635
const format = await getFormatter();
3736

38-
const moreOffersLabel = (count: number) => tProductCard('moreOffers', { count });
39-
4037
const streamablePageData = Streamable.from(async () => {
4138
const customerAccessToken = await getSessionCustomerAccessToken();
4239
const currencyCode = await getPreferredCurrencyCode();
@@ -97,7 +94,6 @@ export default async function Home({ params }: Props) {
9794
description={t('FeaturedProducts.description')}
9895
emptyStateSubtitle={t('FeaturedProducts.emptyStateSubtitle')}
9996
emptyStateTitle={t('FeaturedProducts.emptyStateTitle')}
100-
moreOffersLabel={moreOffersLabel}
10197
products={streamableFeaturedProducts}
10298
title={t('FeaturedProducts.title')}
10399
/>
@@ -107,7 +103,6 @@ export default async function Home({ params }: Props) {
107103
description={t('NewestProducts.description')}
108104
emptyStateSubtitle={t('NewestProducts.emptyStateSubtitle')}
109105
emptyStateTitle={t('NewestProducts.emptyStateTitle')}
110-
moreOffersLabel={moreOffersLabel}
111106
nextLabel={t('NewestProducts.nextProducts')}
112107
previousLabel={t('NewestProducts.previousProducts')}
113108
products={streamableNewestProducts}

core/app/[locale]/(default)/product/[slug]/page.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ export default async function Product({ params, searchParams }: Props) {
8686
setRequestLocale(locale);
8787

8888
const t = await getTranslations('Product');
89-
const tProductCard = await getTranslations('Components.ProductCard');
9089
const format = await getFormatter();
9190

9291
const productId = Number(slug);
@@ -624,7 +623,6 @@ export default async function Product({ params, searchParams }: Props) {
624623
cta={{ label: t('RelatedProducts.cta'), href: '/shop-all' }}
625624
emptyStateSubtitle={t('RelatedProducts.browseCatalog')}
626625
emptyStateTitle={t('RelatedProducts.noRelatedProducts')}
627-
moreOffersLabel={(count) => tProductCard('moreOffers', { count })}
628626
nextLabel={t('RelatedProducts.nextProducts')}
629627
previousLabel={t('RelatedProducts.previousProducts')}
630628
products={streameableRelatedProducts}

core/vibes/soul/primitives/product-card/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { clsx } from 'clsx';
2+
import { useTranslations } from 'next-intl';
23
import {
34
Content as CalloutContent,
45
Description as CalloutDescription,
@@ -40,7 +41,6 @@ export interface ProductCardProps {
4041
imageSizes?: string;
4142
compareLabel?: string;
4243
compareParamName?: string;
43-
moreOffersLabel?: (count: number) => string;
4444
product: Product;
4545
showRating?: boolean;
4646
}
@@ -88,10 +88,11 @@ export function ProductCard({
8888
aspectRatio = '5:6',
8989
compareLabel,
9090
compareParamName,
91-
moreOffersLabel = (count) => `+${count} more ${count === 1 ? 'offer' : 'offers'}`,
9291
imagePriority = false,
9392
imageSizes = '(min-width: 80rem) 20vw, (min-width: 64rem) 25vw, (min-width: 42rem) 33vw, (min-width: 24rem) 50vw, 100vw',
9493
}: ProductCardProps) {
94+
const t = useTranslations('Components.ProductCard');
95+
9596
return (
9697
<article
9798
className={clsx(
@@ -196,7 +197,7 @@ export function ProductCard({
196197
</CalloutTitle>
197198
{promotions.length > 1 && (
198199
<CalloutDescription className="text-xs text-yellow-900/70">
199-
{moreOffersLabel(promotions.length - 1)}
200+
{t('moreOffers', { count: promotions.length - 1 })}
200201
</CalloutDescription>
201202
)}
202203
</CalloutHeader>

core/vibes/soul/sections/featured-product-carousel/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export interface FeaturedProductCarouselProps {
2121
previousLabel?: string;
2222
nextLabel?: string;
2323
hideOverflow?: boolean;
24-
moreOffersLabel?: (count: number) => string;
2524
}
2625

2726
// eslint-disable-next-line valid-jsdoc
@@ -50,7 +49,6 @@ export function FeaturedProductCarousel({
5049
previousLabel,
5150
nextLabel,
5251
hideOverflow = false,
53-
moreOffersLabel,
5452
}: FeaturedProductCarouselProps) {
5553
return (
5654
<SectionLayout containerSize="2xl">
@@ -76,7 +74,6 @@ export function FeaturedProductCarousel({
7674
emptyStateSubtitle={emptyStateSubtitle}
7775
emptyStateTitle={emptyStateTitle}
7876
hideOverflow={hideOverflow}
79-
moreOffersLabel={moreOffersLabel}
8077
nextLabel={nextLabel}
8178
placeholderCount={placeholderCount}
8279
previousLabel={previousLabel}

core/vibes/soul/sections/featured-product-list/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export interface FeaturedProductsListProps {
1717
emptyStateTitle?: Streamable<string>;
1818
emptyStateSubtitle?: Streamable<string>;
1919
placeholderCount?: number;
20-
moreOffersLabel?: (count: number) => string;
2120
}
2221

2322
// eslint-disable-next-line valid-jsdoc
@@ -42,7 +41,6 @@ export function FeaturedProductList({
4241
emptyStateTitle,
4342
emptyStateSubtitle,
4443
placeholderCount,
45-
moreOffersLabel,
4644
}: FeaturedProductsListProps) {
4745
return (
4846
<StickySidebarLayout
@@ -70,7 +68,6 @@ export function FeaturedProductList({
7068
<ProductList
7169
emptyStateSubtitle={emptyStateSubtitle}
7270
emptyStateTitle={emptyStateTitle}
73-
moreOffersLabel={moreOffersLabel}
7471
placeholderCount={placeholderCount}
7572
products={products}
7673
showCompare={false}

core/vibes/soul/sections/product-carousel/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export interface ProductCarouselProps {
3232
showButtons?: boolean;
3333
showScrollbar?: boolean;
3434
hideOverflow?: boolean;
35-
moreOffersLabel?: (count: number) => string;
3635
}
3736

3837
// eslint-disable-next-line valid-jsdoc
@@ -65,7 +64,6 @@ export function ProductCarousel({
6564
showButtons = true,
6665
showScrollbar = true,
6766
hideOverflow = true,
68-
moreOffersLabel,
6967
}: ProductCarouselProps) {
7068
return (
7169
<Stream
@@ -104,7 +102,6 @@ export function ProductCarousel({
104102
aspectRatio={aspectRatio}
105103
colorScheme={colorScheme}
106104
imageSizes="(min-width: 42rem) 25vw, (min-width: 32rem) 33vw, (min-width: 28rem) 50vw, 100vw"
107-
moreOffersLabel={moreOffersLabel}
108105
product={{ id, ...product }}
109106
/>
110107
</CarouselItem>

core/vibes/soul/sections/product-list/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ interface ProductListProps {
2626
removeLabel?: Streamable<string>;
2727
maxItems?: number;
2828
maxCompareLimitMessage?: Streamable<string>;
29-
moreOffersLabel?: (count: number) => string;
3029
}
3130

3231
// eslint-disable-next-line valid-jsdoc
@@ -62,7 +61,6 @@ export function ProductList({
6261
removeLabel: streamableRemoveLabel,
6362
maxItems,
6463
maxCompareLimitMessage: streamableMaxCompareLimitMessage,
65-
moreOffersLabel,
6664
}: ProductListProps) {
6765
return (
6866
<Stream
@@ -110,7 +108,6 @@ export function ProductList({
110108
compareParamName={compareParamName}
111109
imageSizes="(min-width: 80rem) 20vw, (min-width: 64rem) 25vw, (min-width: 42rem) 33vw, (min-width: 24rem) 50vw, 100vw"
112110
key={product.id}
113-
moreOffersLabel={moreOffersLabel}
114111
product={product}
115112
showCompare={showCompare}
116113
showRating={showRating}

0 commit comments

Comments
 (0)