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' }, ] function GalleryToolbar({ sort, onSort }) { return (
Sort
{SORT_OPTIONS.map((opt) => ( ))}
) } export default function ProfileGalleryPanel({ artworks, username }) { 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 response = await fetch(`/api/profile/${encodeURIComponent(username)}/artworks?sort=${newSort}`, { headers: { Accept: 'application/json' }, }) if (!response.ok) { return } const data = await response.json() setItems(data.data ?? data) setNextCursor(data.next_cursor ?? null) } catch (_) {} } return ( <>
) }