import React from 'react' import { Plus, Check, Route } from 'lucide-react' import PlaceAvatar from '../shared/PlaceAvatar' import { getCategoryIcon } from '../shared/categoryIcons' import type { Place, Category } from '../../types' interface MemoPlaceRowProps { place: Place category: Category | undefined isSelected: boolean isPlanned: boolean inDay: boolean isChecked: boolean selectMode: boolean selectedDayId: number | null canEditPlaces: boolean isMobile: boolean t: (key: string, params?: Record) => string onPlaceClick: (id: number | null) => void onContextMenu: (e: React.MouseEvent, place: Place) => void onAssignToDay: (placeId: number, dayId?: number) => void toggleSelected: (id: number) => void setDayPickerPlace: (place: any) => void } export const MemoPlaceRow = React.memo(function MemoPlaceRow({ place, category: cat, isSelected, isPlanned, inDay, isChecked, selectMode, selectedDayId, canEditPlaces, isMobile, t, onPlaceClick, onContextMenu, onAssignToDay, toggleSelected, setDayPickerPlace, }: MemoPlaceRowProps) { const hasGeometry = Boolean(place.route_geometry) return (
{ e.dataTransfer.setData('placeId', String(place.id)) e.dataTransfer.effectAllowed = 'copy' window.__dragData = { placeId: String(place.id) } }} onClick={() => { if (selectMode) { toggleSelected(place.id) } else if (isMobile) { setDayPickerPlace(place) } else { onPlaceClick(isSelected ? null : place.id) } }} onContextMenu={selectMode ? undefined : e => onContextMenu(e, place)} style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '9px 14px 9px 16px', cursor: selectMode ? 'pointer' : 'grab', background: isChecked ? 'color-mix(in srgb, var(--accent) 8%, transparent)' : isSelected ? 'var(--border-faint)' : 'transparent', borderBottom: '1px solid var(--border-faint)', transition: 'background 0.1s', contentVisibility: 'auto', containIntrinsicSize: '0 52px', }} onMouseEnter={e => { if (!isSelected && !isChecked) e.currentTarget.style.background = 'var(--bg-hover)' }} onMouseLeave={e => { if (!isSelected && !isChecked) e.currentTarget.style.background = 'transparent' }} > {selectMode && (
{isChecked && }
)}
{hasGeometry && } {cat && (() => { const CatIcon = getCategoryIcon(cat.icon) return })()} {place.name}
{(place.description || place.address || cat?.name) && (
{place.description || place.address || cat?.name}
)}
{!selectMode && !inDay && selectedDayId && ( )}
) })