Skip to content

Commit 2d2e520

Browse files
committed
feat: Add out-of-stock/backorder message to product lists - Apply comments
1 parent 21fa784 commit 2d2e520

6 files changed

Lines changed: 20 additions & 19 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export default async function Brand(props: Props) {
133133
const products = search.products.items;
134134

135135
const { defaultOutOfStockMessage, showOutOfStockMessage, showBackorderMessage } =
136-
settings?.inventory || {};
136+
settings?.inventory ?? {};
137137

138138
return productCardTransformer(
139139
products,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export default async function Category(props: Props) {
146146
const products = search.products.items;
147147

148148
const { defaultOutOfStockMessage, showOutOfStockMessage, showBackorderMessage } =
149-
settings?.inventory || {};
149+
settings?.inventory ?? {};
150150

151151
return productCardTransformer(
152152
products,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export default async function Search(props: Props) {
118118
const products = search.products.items;
119119

120120
const { defaultOutOfStockMessage, showOutOfStockMessage, showBackorderMessage } =
121-
settings?.inventory || {};
121+
settings?.inventory ?? {};
122122

123123
return productCardTransformer(
124124
products,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default async function Home({ params }: Props) {
3737
const featuredProducts = removeEdgesAndNodes(data.site.featuredProducts);
3838

3939
const { defaultOutOfStockMessage, showOutOfStockMessage, showBackorderMessage } =
40-
data.site.settings?.inventory || {};
40+
data.site.settings?.inventory ?? {};
4141

4242
return productCardTransformer(
4343
featuredProducts,
@@ -53,7 +53,7 @@ export default async function Home({ params }: Props) {
5353
const newestProducts = removeEdgesAndNodes(data.site.newestProducts);
5454

5555
const { defaultOutOfStockMessage, showOutOfStockMessage, showBackorderMessage } =
56-
data.site.settings?.inventory || {};
56+
data.site.settings?.inventory ?? {};
5757

5858
return productCardTransformer(
5959
newestProducts,

core/data-transformers/product-card-transformer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const getInventoryMessage = (
2121
return undefined;
2222
}
2323

24-
const { availableForBackorder, unlimitedBackorder } = product.inventory.aggregated || {};
24+
const { availableForBackorder, unlimitedBackorder } = product.inventory.aggregated ?? {};
2525

2626
const hasBackorderAvailablity = !!availableForBackorder || unlimitedBackorder;
2727

@@ -37,7 +37,7 @@ const getInventoryMessage = (
3737

3838
const inventoryByLocation = removeEdgesAndNodes(baseVariant.inventory.byLocation).at(0);
3939

40-
return inventoryByLocation?.backorderMessage || undefined;
40+
return inventoryByLocation?.backorderMessage ?? undefined;
4141
};
4242

4343
export const singleProductCardTransformer = (

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,19 @@ export function ProductCard({
135135
>
136136
{title}
137137
</span>
138-
139-
<span
140-
className={clsx(
141-
'mb-1.5 block text-sm font-normal',
142-
{
143-
light: 'text-[var(--product-card-light-subtitle,hsl(var(--foreground)/75%))]',
144-
dark: 'text-[var(--product-card-dark-subtitle,hsl(var(--background)/75%))]',
145-
}[colorScheme],
146-
)}
147-
>
148-
{subtitle}
149-
</span>
138+
{subtitle != null && subtitle !== '' && (
139+
<span
140+
className={clsx(
141+
'mb-1.5 block text-sm font-normal',
142+
{
143+
light: 'text-[var(--product-card-light-subtitle,hsl(var(--foreground)/75%))]',
144+
dark: 'text-[var(--product-card-dark-subtitle,hsl(var(--background)/75%))]',
145+
}[colorScheme],
146+
)}
147+
>
148+
{subtitle}
149+
</span>
150+
)}
150151
{price != null && <PriceLabel colorScheme={colorScheme} price={price} />}
151152
<span
152153
className={clsx(

0 commit comments

Comments
 (0)