import React, { useState } from 'react' import MasonryGallery from '../../gallery/MasonryGallery' const SORT_OPTIONS = [ { value: 'latest', label: 'Latest' }, { value: 'trending', label: 'Trending' }, { value: 'rising', label: 'Rising' }, { value: 'views', label: 'Most Viewed' }, { value: 'favs', label: 'Most Favourited' }, ] /** * Featured artworks horizontal scroll strip. */ function FeaturedStrip({ featuredArtworks }) { if (!featuredArtworks?.length) return null return (

Featured

{featuredArtworks.slice(0, 5).map((art) => (
{art.name}

{art.name}

{art.label && (

{art.label}

)}
))}
) } function slugify(str) { return (str || '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '') } /** * TabArtworks * Features: sort selector, featured strip, masonry-style artwork grid, * skeleton loading, empty state, load-more pagination. */ export default function TabArtworks({ artworks, featuredArtworks, username, isActive }) { const [sort, setSort] = useState('latest') const [items, setItems] = useState(artworks?.data ?? artworks ?? []) const [nextCursor, setNextCursor] = useState(artworks?.next_cursor ?? null) const handleSort = async (newSort) => { setSort(newSort) setItems([]) try { const res = await fetch(`/api/profile/${encodeURIComponent(username)}/artworks?sort=${newSort}`, { headers: { Accept: 'application/json' }, }) if (res.ok) { const data = await res.json() setItems(data.data ?? data) setNextCursor(data.next_cursor ?? null) } } catch (_) {} } return (
{/* Featured strip */} {/* Sort bar */}
Sort
{SORT_OPTIONS.map((opt) => ( ))}
{/* Shared masonry gallery component reused from discover/explore */}
) }