import { useState } from 'react' import { Plus, X, MapPin } from 'lucide-react' import { useTranslation } from '../../i18n' import type { Place, AssignmentsMap } from '../../types' export function MobileAddPlaceButton({ dayId, places, assignments, onAssign, onAddNew }: { dayId: number places: Place[] assignments: AssignmentsMap onAssign?: (placeId: number, dayId: number) => void onAddNew?: () => void }) { const { t } = useTranslation() const [open, setOpen] = useState(false) const [search, setSearch] = useState('') // Find places not assigned to this day const assignedToDay = new Set((assignments[String(dayId)] || []).map(a => a.place_id)) const available = places.filter(p => !assignedToDay.has(p.id)) const filtered = search.trim() ? available.filter(p => p.name.toLowerCase().includes(search.toLowerCase())) : available return (
{!open ? ( ) : (
setSearch(e.target.value)} placeholder={t('dayplan.mobile.searchPlaces')} style={{ flex: 1, border: 'none', outline: 'none', background: 'transparent', fontSize: 13, fontFamily: 'inherit', color: 'var(--text-primary)' }} />
{filtered.length === 0 && (
{available.length === 0 ? t('dayplan.mobile.allAssigned') : t('dayplan.mobile.noMatch')}
)} {filtered.slice(0, 20).map(p => ( ))}
{onAddNew && ( )}
)}
) }