diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2025-11-22 19:31:34 +0100 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2025-11-22 19:31:34 +0100 |
| commit | 66c63b1f11f6936c50101c55d5867807960bc618 (patch) | |
| tree | e57a17c670affe9c4ea8457f0bdf7a2709a28953 /src/frontend | |
| parent | b6f8822c4f05602a7f7b7a96288829722b3988fc (diff) | |
feat: Add error handling and logging for map point clicks in StopMap component
Diffstat (limited to 'src/frontend')
| -rw-r--r-- | src/frontend/app/routes/map.tsx | 28 |
1 files changed, 20 insertions, 8 deletions
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 ( |
