From 66c63b1f11f6936c50101c55d5867807960bc618 Mon Sep 17 00:00:00 2001
From: Ariel Costas Guerrero <ariel@costas.dev>
Date: Sat, 22 Nov 2025 19:31:34 +0100
Subject: feat: Add error handling and logging for map point clicks in StopMap
 component

---
 src/frontend/app/routes/map.tsx | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

(limited to 'src/frontend/app/routes/map.tsx')

diff --git a/src/frontend/app/routes/map.tsx b/src/frontend/app/routes/map.tsx
index 2af53d8..ef3f625 100644
--- a/src/frontend/app/routes/map.tsx
+++ b/src/frontend/app/routes/map.tsx
@@ -55,6 +55,7 @@ export default function StopMap() {
       return;
     }
     const feature = features[0];
+    console.debug("Map click feature:", feature);
     const props: any = feature.properties;
 
     handlePointClick(feature);
@@ -141,15 +142,26 @@ export default function StopMap() {
 
   const handlePointClick = (feature: any) => {
     const props: any = feature.properties;
+    if (!props || !props.stopId) {
+      console.warn("Invalid feature properties:", props);
+      return;
+    }
+
+    const stopId = parseInt(props.stopId, 10);
+
     // fetch full stop to get lines array
-    StopDataProvider.getStopById(region, props.stopId).then((stop) => {
-      if (!stop) {
-        console.warn("Stop not found:", props.stopId);
-        return;
-      }
-      setSelectedStop(stop);
-      setIsSheetOpen(true);
-    });
+    StopDataProvider.getStopById(region, stopId)
+      .then((stop) => {
+        if (!stop) {
+          console.warn("Stop not found:", stopId);
+          return;
+        }
+        setSelectedStop(stop);
+        setIsSheetOpen(true);
+      })
+      .catch((err) => {
+        console.error("Error fetching stop details:", err);
+      });
   };
 
   return (
-- 
cgit v1.3

