import React from 'react'; import { IcClock, IcLocation, IcNavBack, IcSwapVertical } from '../../res/icons'; import type { MapSearchHistoryEntry } from '../../state'; import { isCurrentLocationRoutePoint, type RoutePoint } from '../../hooks/useRouting'; import { useMapGestures } from '../../hooks/useMapGestures'; import { useMapStrings } from '../../hooks/useMapStrings'; type TransportModeKey = 'driving' | 'transit' | 'walking' | 'cycling'; type ModeTab = { key: string; icon: React.ComponentType<{ size?: number; className?: string; strokeWidth?: number; fill?: string }>; }; type RouteSide = 'origin' | 'destination'; const FIELD_ROW_MIN_H = 'min-h-14'; export const RouteSetupOverlay: React.FC<{ origin: RoutePoint | null; anchorSide: RouteSide; searchHistory: MapSearchHistoryEntry[]; selectedTransportMode: TransportModeKey; setAnchorSide: (side: RouteSide) => void; setSelectedTransportMode: (mode: TransportModeKey) => void; modes: ModeTab[]; onOpenPointPicker: (side: RouteSide, initialQuery?: string) => void; onSelectHistoryPlace: (placeId: string, side: RouteSide) => void; }> = ({ origin, anchorSide, searchHistory, selectedTransportMode, setAnchorSide, setSelectedTransportMode, modes, onOpenPointPicker, onSelectHistoryPlace, }) => { const s = useMapStrings(); const { bindBack, bindTap } = useMapGestures(); const originLabel = origin?.name || s.your_location; const transportModes = modes.filter((mode) => mode.key !== 'cycling'); const placeHistory = searchHistory.filter( (item): item is MapSearchHistoryEntry & { kind: 'place'; placeId: string } => item.kind === 'place' && typeof item.placeId === 'string' && item.placeId.length > 0, ); const fieldBase = 'flex w-full items-center gap-3 rounded-xl border bg-white px-3.5 text-left transition-colors active:bg-gray-50'; return (
{transportModes.map((mode) => { const Icon = mode.icon; const active = selectedTransportMode === mode.key; return ( ); })}
{placeHistory.map((item) => ( ))}
); };