diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2025-11-22 18:07:33 +0100 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2025-11-22 18:33:25 +0100 |
| commit | be2391954dd7653f1eecb4f650228d41038ff27b (patch) | |
| tree | c3d6aae9bac03b40cb14ce6b4fa087fe5b8d706c /src/frontend/app/components/StopMapModal.tsx | |
| parent | 2901dddf0309942583ffc812168a149b65b3bdc6 (diff) | |
feat: Update StopMapModal and Estimates to use selectedCirculationId for better clarity and consistency
Diffstat (limited to 'src/frontend/app/components/StopMapModal.tsx')
| -rw-r--r-- | src/frontend/app/components/StopMapModal.tsx | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/frontend/app/components/StopMapModal.tsx b/src/frontend/app/components/StopMapModal.tsx index 91cd513..ad73fc2 100644 --- a/src/frontend/app/components/StopMapModal.tsx +++ b/src/frontend/app/components/StopMapModal.tsx @@ -22,6 +22,7 @@ export interface Position { } export interface ConsolidatedCirculationForMap { + id: string; line: string; route: string; currentPosition?: Position; @@ -37,7 +38,7 @@ interface StopMapModalProps { region: RegionId; isOpen: boolean; onClose: () => void; - selectedCirculationIndex?: number; + selectedCirculationId?: string; } export const StopMapModal: React.FC<StopMapModalProps> = ({ @@ -46,7 +47,7 @@ export const StopMapModal: React.FC<StopMapModalProps> = ({ region, isOpen, onClose, - selectedCirculationIndex, + selectedCirculationId, }) => { const { theme } = useApp(); const [styleSpec, setStyleSpec] = useState<any | null>(null); @@ -62,17 +63,19 @@ export const StopMapModal: React.FC<StopMapModalProps> = ({ [circulations] ); - // Use selectedCirculationIndex if provided, otherwise use first bus with position + // Use selectedCirculationId if provided, otherwise use first bus with position const selectedBus = useMemo(() => { - if (selectedCirculationIndex !== undefined) { - const circulation = circulations[selectedCirculationIndex]; + if (selectedCirculationId !== undefined) { + const circulation = circulations.find( + (c) => c.id === selectedCirculationId + ); if (circulation?.currentPosition) { return circulation; } } // Fallback to first bus with position return busesWithPosition.length > 0 ? busesWithPosition[0] : null; - }, [selectedCirculationIndex, circulations, busesWithPosition]); + }, [selectedCirculationId, circulations, busesWithPosition]); const center = useMemo(() => { if (selectedBus?.currentPosition) { |
