mirror of
https://github.com/vercel/commerce.git
synced 2025-06-15 11:51:21 +00:00
Apply const quantity guard
This commit is contained in:
parent
fa1306916c
commit
a87ad94d2f
@ -3,6 +3,8 @@ import { getCollectionProducts } from 'lib/shopify';
|
|||||||
import type { Product } from 'lib/shopify/types';
|
import type { Product } from 'lib/shopify/types';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
|
|
||||||
|
const MINIMUM_PRODUCTS_QUANTITY = 3;
|
||||||
|
|
||||||
function ThreeItemGridItem({
|
function ThreeItemGridItem({
|
||||||
item,
|
item,
|
||||||
size,
|
size,
|
||||||
@ -47,7 +49,7 @@ export async function ThreeItemGrid() {
|
|||||||
collection: 'hidden-homepage-featured-items'
|
collection: 'hidden-homepage-featured-items'
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!homepageItems[0] || !homepageItems[1] || !homepageItems[2]) return null;
|
if (homepageItems.length < MINIMUM_PRODUCTS_QUANTITY) return null;
|
||||||
|
|
||||||
const [firstProduct, secondProduct, thirdProduct] = homepageItems;
|
const [firstProduct, secondProduct, thirdProduct] = homepageItems;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user