Fix: Ensure dummy getCollectionProducts safely handles empty generic product list

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]` without
first ensuring that the `genericProducts` array (fetched from a dummy
`getProducts({query: "generic"})` call) was not empty.

The logic has been updated to check if `genericProducts.length > 0`
before accessing `genericProducts[0]`. If the array is empty,
`dummyCollectionProductsList` is set to an empty array, preventing
the assignment of `undefined` to a variable typed as `Product[]`.
This commit is contained in:
google-labs-jules[bot] 2025-05-23 07:51:21 +00:00
parent 1388b81d0e
commit 128daa3f8b

Diff Content Not Available