From 3676b1d1d9216a676c7d5a40affa5b3256ca8df3 Mon Sep 17 00:00:00 2001
From: Ariel Costas Guerrero <ariel@costas.dev>
Date: Sun, 20 Apr 2025 20:15:55 +0200
Subject: Refactor stop data handling with caching and custom names support

---
 src/pages/Map.tsx | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

(limited to 'src/pages/Map.tsx')

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} />
-- 
cgit v1.3

