"use client"; import React, { useState, useEffect } from 'react'; import { getCollections } from '@/hooks/use-shopify-collections'; import CollectionCard from './CollectionCard'; import { Button } from './ui/button'; interface CollectionImage { url: string; altText?: string; } interface Collection { id: string; title: string; handle: string; description?: string; image?: CollectionImage; } const Collections: React.FC = () => { const [collections, setCollections] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { const fetchCollections = async () => { try { setLoading(true); setError(null); const collectionData = await getCollections(20); setCollections(collectionData); } catch (err) { console.error('Error fetching collections:', err); setError(err instanceof Error ? err.message : 'Failed to load collections'); } finally { setLoading(false); } }; fetchCollections(); }, []); if (loading) { return (

Our Collections

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

Our Collections

Failed to Load Collections

{error}

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

Our Collections

No Collections Found

Check back later or configure your Shopify store connection.

); } return (

Our Collections

{/* Collections Grid */}
{collections.map((collection) => ( ))}
); }; export default Collections;