From 1e1eeb3b3792bfe3d902d4a5ddc71848ffee33da Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 23 May 2025 07:56:43 +0000 Subject: [PATCH] Fix: Ensure getCollectionProducts safely handles undefined genericProduct[0] Resolves a TypeScript type error in `lib/shopify/index.ts` within the dummy data logic for the `getCollectionProducts` function: "Type 'Product | undefined' is not assignable to type 'Product'." The error occurred when attempting to use `genericProducts[0]` to populate `dummyCollectionProductsList` without definitively confirming that `genericProducts[0]` was not `undefined` (i.e., when the `genericProducts` array was empty). The logic in the fallback case for dummy data in `getCollectionProducts` has been confirmed/updated to explicitly check `genericProducts.length > 0` before accessing `genericProducts[0]`. If the `genericProducts` array is empty, `dummyCollectionProductsList` is correctly assigned an empty array, preventing the type error.