diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2025-04-20 20:15:55 +0200 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2025-04-20 20:15:55 +0200 |
| commit | 3676b1d1d9216a676c7d5a40affa5b3256ca8df3 (patch) | |
| tree | efa63a0d21ae52e32e405fe7b4ce56b02d782e86 /src/pages/Map.tsx | |
| parent | c86b4655f72c86362c064dd50bb701782b39e6eb (diff) | |
Refactor stop data handling with caching and custom names support
Diffstat (limited to 'src/pages/Map.tsx')
| -rw-r--r-- | src/pages/Map.tsx | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/pages/Map.tsx b/src/pages/Map.tsx index af95bf9..1f0a9e0 100644 --- a/src/pages/Map.tsx +++ b/src/pages/Map.tsx @@ -41,17 +41,9 @@ export function StopMap() { const { mapState } = useApp(); useEffect(() => { - StopDataProvider.getStops().then((stops) => { setStops(stops); }); + StopDataProvider.getStops().then(setStops); }, []); - const getDisplayName = (stop: Stop): string => { - if (typeof stop.name === 'string') { - return stop.name; - } - - return stop.name.intersect || stop.name.original; - } - return ( <MapContainer center={mapState.center} @@ -66,10 +58,10 @@ export function StopMap() { <EnhancedLocateControl /> <MapEventHandler /> <MarkerClusterGroup> - {stops.map((stop) => ( + {stops.map(stop => ( <Marker key={stop.stopId} position={[stop.latitude, stop.longitude] as LatLngTuple} icon={icon}> <Popup> - <Link to={`/estimates/${stop.stopId}`}>{getDisplayName(stop)}</Link> + <Link to={`/estimates/${stop.stopId}`}>{StopDataProvider.getDisplayName(stop)}</Link> <br /> {stop.lines.map((line) => ( <LineIcon key={line} line={line} /> |
