import React from 'react'
import CollectionCard from '../../components/profile/collections/CollectionCard'
function normalizeItems(items) {
if (!Array.isArray(items)) return []
return items.filter((item) => item && typeof item === 'object')
}
function SectionHeader({ title, subtitle, href, ctaLabel = 'See all' }) {
return (
{title}
{subtitle ?
{subtitle}
: null}
{href ? (
{ctaLabel} →
) : null}
)
}
function CollectionStrip({ items }) {
if (!items.length) return null
return (
{items.map((collection) => (
))}
)
}
function CollectionSection({ title, subtitle, href, items, limit = 3, ctaLabel }) {
const normalized = normalizeItems(items).slice(0, limit)
if (!normalized.length) return null
return (
)
}
export default function HomeCollections({
featured,
recent,
trending,
editorial,
community,
isLoggedIn = false,
}) {
const featuredItems = normalizeItems(featured)
const recentItems = normalizeItems(recent)
const trendingItems = normalizeItems(trending)
const editorialItems = normalizeItems(editorial)
const communityItems = normalizeItems(community)
if (!featuredItems.length && !recentItems.length && !trendingItems.length && !editorialItems.length && !communityItems.length) {
return null
}
return (
Curated Collections
Hand-built galleries, smart collections, and community showcases worth opening next.
{isLoggedIn && recentItems.length ? Recent : null}
{featuredItems.length ? Featured : null}
{communityItems.length ? Community : null}
{isLoggedIn ? (
) : null}
)
}