From a87ad94d2fbb90e5b6cde7ad62fb8ce6de0b0ba1 Mon Sep 17 00:00:00 2001 From: Mattia Zanella Date: Tue, 20 May 2025 22:35:30 +0200 Subject: [PATCH] Apply const quantity guard --- components/grid/three-items.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/grid/three-items.tsx b/components/grid/three-items.tsx index cd6302904..2275cd9b2 100644 --- a/components/grid/three-items.tsx +++ b/components/grid/three-items.tsx @@ -3,6 +3,8 @@ import { getCollectionProducts } from 'lib/shopify'; import type { Product } from 'lib/shopify/types'; import Link from 'next/link'; +const MINIMUM_PRODUCTS_QUANTITY = 3; + function ThreeItemGridItem({ item, size, @@ -47,7 +49,7 @@ export async function ThreeItemGrid() { 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;