'use client' import { useEffect, useState } from 'react' import Link from 'next/link' import Image from 'next/image' interface MedusaCollection { id: string; title: string; handle: string; metadata?: { image?: string } } export default function BrandCarouselSection() { const [collections, setCollections] = useState([]) const [loading, setLoading] = useState(true) useEffect(() => { fetch('/api/medusa/store/collections?limit=20') .then(r => r.ok ? r.json() : Promise.reject()) .then(d => { setCollections(d.collections ?? []); setLoading(false) }) .catch(() => setLoading(false)) }, []) if (loading || collections.length === 0) return null return (

Shop by Collection

{collections.map(col => (
{col.metadata?.image ? ( {col.title} ) : (
{col.title.slice(0, 2)}
)}

{col.title}

))}
) }