import React, { useId } from 'react' import { Search, MapPin, Loader2, Copy, CalendarDays } from 'lucide-react' import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, fs } from '../shared/DialogShell' import { INPUT } from '../shared/dialogParts' import type { TranslationFn } from '../../types' import { useTripCopyPicker } from './useTripCopyPicker' interface CopyToTripModalProps { isOpen: boolean onClose: () => void /** The collection place ids to copy. */ placeIds: number[] /** Delegates to collectionStore.copyToTrip; returns the server reconcile result. */ onCopy: (tripId: number) => Promise<{ copied: number; skipped: { id: number; name: string }[] }> t: TranslationFn } /** * Trip picker for "Copy to trip" — lists the user's trips (searchable), copies * the selected collection places into the chosen trip and reconciles the server * dedup result into a copied / skipped-duplicates toast. Works for a single * place (detail panel) and bulk select-mode ("Copy N to trip"). */ export default function CopyToTripModal({ isOpen, onClose, placeIds, onCopy, t }: CopyToTripModalProps): React.ReactElement | null { const labelId = useId() const { loading, search, setSearch, filtered, busyTripId, dateRange, handleCopy } = useTripCopyPicker({ open: isOpen, onCopy, onClose, t, emptySelection: placeIds.length === 0 }) if (!isOpen) return null return ( } tint={NEUTRAL_TINT} labelId={labelId} onClose={onClose} title={t('collections.copyN', { count: placeIds.length })} /> )} footer={( {t('common.cancel')} )} >
{loading ? (
) : filtered.length === 0 ? (

{t('collections.noTrips')}

) : (
{filtered.map(trip => { const busy = busyTripId === trip.id const range = dateRange(trip) return ( ) })}
)}
) }