"use client"; import React from 'react'; import ProductCard from './ProductCard'; import { useProducts } from '@/hooks/use-shopify-products'; import { Button } from './ui/button'; interface ProductImage { url: string; altText?: string; } interface ProductPrice { amount: string; currencyCode: string; } interface ProductVariant { id: string; title: string; price: ProductPrice; availableForSale: boolean; } interface Product { id: string; title: string; description?: string; handle: string; images: { edges: Array<{ node: ProductImage; }>; }; priceRange: { minVariantPrice: ProductPrice; }; compareAtPriceRange?: { minVariantPrice: ProductPrice; }; variants: { edges: Array<{ node: ProductVariant; }>; }; } interface ProductsProps { title?: string; limit?: number; showLoadMore?: boolean; onViewDetails?: (product: Product) => void; } const Products: React.FC = ({ title = "Our Products", limit = 12, showLoadMore = true, onViewDetails }) => { const { products, loading, error, refetch } = useProducts({ first: limit, sortKey: 'CREATED_AT', reverse: true }); const handleAddToCart = async (product: Product) => { console.log('Adding to cart:', product); }; if (loading) { return (

{title}

{/* Loading Skeleton */}
{Array.from({ length: 8 }).map((_, index) => (
))}
); } if (error) { return (

{title}

Failed to Load Products

{error}

); } if (products.length === 0) { return (

{title}

No Products Found

Check back later or configure your Shopify store connection.

); } return (

{title}

{/* Products Grid */}
{products.map((product) => ( ))}
{/* Load More Button */} {showLoadMore && products.length >= limit && (
)}
); }; export default Products;