import React, { useId } from 'react' import { Bookmark, BookmarkCheck, Check, CheckCircle2, Loader2, Plus } from 'lucide-react' import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, PILL, fs } from '../shared/DialogShell' import { useTranslation } from '../../i18n' import StatusBadge from './StatusBadge' import { VISITED_EVERYWHERE_BUSY, useSaveToCollection } from './useSaveToCollection' /** * Globally-mounted list picker for the "Save to Collection" entry points * (PlaceInspector footer button + the two trip-sidebar context menus). Reads the * active target from saveToCollectionStore, shows every list the user owns or * co-owns, and toggles the place in/out of each — a check marks the lists that * already hold it. Each change refreshes membership and bumps the store version * so the inspector bookmark indicator stays in sync. One mount, no prop drilling. */ export default function SaveToCollectionModal(): React.ReactElement | null { const { target, close, lists, loading, busyId, savedByCollection, unvisited, handleStatus, handleVisitedEverywhere, handleToggle, openCollections } = useSaveToCollection() const { t } = useTranslation() const labelId = useId() if (!target) return null return ( } tint={NEUTRAL_TINT} labelId={labelId} onClose={close} eyebrow={t('collections.pickList')} title={target.name} // One tap for "I have been here", however many lists hold it (#1469). pills={unvisited.length > 0 ? ( ) : undefined} /> )} footer={lists.length > 0 ? ( }>{t('collections.viewInCollection')} ) : undefined} > {loading ? (
) : lists.length === 0 ? (

{t('collections.noListsYet')}

}>{t('collections.newList')}
) : (
{lists.map(list => { const entry = savedByCollection.get(list.id) const saved = !!entry const busy = busyId === list.id return ( ) })}
)}
) }