import React, { useEffect, useState } from 'react' import { Bookmark, ArrowRight, MapPin } from 'lucide-react' import { useNavigate } from 'react-router' import { useTranslation } from '../../i18n' import { entityGradient } from '../../utils/gradients' import { useCollectionLists } from './useCollectionLists' import { readShownCollections, rememberShownCollections } from './collectionsWidgetMemory' /** * Dashboard sidebar widget — a glassy `.tool` card that surfaces the user's * saved-place LISTS as compact colour-washed badges (a mini version of the * collections hero): each badge shows the list's cover image (tinted with its * colour) or a colour gradient, its name and place count, and jumps to that * list. Fetches only list() (per-list place_count), so no N+1. */ export default function CollectionsWidget({ onOpen }: { onOpen: () => void }): React.ReactElement { const { t } = useTranslation() const navigate = useNavigate() const { lists, loading } = useCollectionLists() const [expected] = useState(readShownCollections) useEffect(() => { if (!loading) rememberShownCollections(Math.min(lists.length, 6)) }, [loading, lists.length]) return (
{t('collections.widget.title')}
{loading ? ( expected ? (
{Array.from({ length: expected }, (_, i) =>
)}
) : (
{t('collections.widget.empty')}
) ) : lists.length === 0 ? (
{t('collections.widget.empty')}
) : (
{lists.slice(0, 6).map(list => ( ))}
)}
) }