From 276e73412abef28c222c52a84334d49f5e414f3c Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Mon, 17 Nov 2025 23:39:08 +0100 Subject: Use consolidated data API in map sheet with shared card component (#100) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: arielcostas <94913521+arielcostas@users.noreply.github.com> Co-authored-by: Ariel Costas Guerrero --- src/frontend/app/routes/estimates-$id.tsx | 10 +++++----- src/frontend/app/routes/home.tsx | 14 +++++++------- src/frontend/app/routes/map.tsx | 12 +++++++++++- src/frontend/app/routes/settings.tsx | 4 ++-- src/frontend/app/routes/stops-$id.tsx | 8 ++++---- src/frontend/app/routes/timetable-$id.tsx | 20 ++++++++++---------- 6 files changed, 39 insertions(+), 29 deletions(-) (limited to 'src/frontend/app/routes') diff --git a/src/frontend/app/routes/estimates-$id.tsx b/src/frontend/app/routes/estimates-$id.tsx index 4efa797..e4006ef 100644 --- a/src/frontend/app/routes/estimates-$id.tsx +++ b/src/frontend/app/routes/estimates-$id.tsx @@ -38,7 +38,7 @@ interface ErrorInfo { const loadData = async ( region: RegionId, - stopId: string, + stopId: string ): Promise => { const regionConfig = getRegionConfig(region); const resp = await fetch(`${regionConfig.estimatesEndpoint}?id=${stopId}`, { @@ -56,7 +56,7 @@ const loadData = async ( const loadTimetableData = async ( region: RegionId, - stopId: string, + stopId: string ): Promise => { const regionConfig = getRegionConfig(region); @@ -72,7 +72,7 @@ const loadTimetableData = async ( headers: { Accept: "application/json", }, - }, + } ); if (!resp.ok) { @@ -201,7 +201,7 @@ export default function Estimates() { StopDataProvider.pushRecent(region, parseInt(params.id ?? "")); setFavourited( - StopDataProvider.isFavourite(region, parseInt(params.id ?? "")), + StopDataProvider.isFavourite(region, parseInt(params.id ?? "")) ); }, [params.id, region, loadEstimatesData, loadTimetableDataAsync]); @@ -323,7 +323,7 @@ export default function Estimates() { onRetry={loadEstimatesData} title={t( "errors.estimates_title", - "Error al cargar estimaciones", + "Error al cargar estimaciones" )} /> ) : data ? ( diff --git a/src/frontend/app/routes/home.tsx b/src/frontend/app/routes/home.tsx index 88c774b..2909999 100644 --- a/src/frontend/app/routes/home.tsx +++ b/src/frontend/app/routes/home.tsx @@ -29,7 +29,7 @@ export default function StopList() { const randomPlaceholder = useMemo( () => t("stoplist.search_placeholder"), - [t], + [t] ); const fuse = useMemo( @@ -38,7 +38,7 @@ export default function StopList() { threshold: 0.3, keys: ["name.original", "name.intersect", "stopId"], }), - [data], + [data] ); const requestUserLocation = useCallback(() => { @@ -59,7 +59,7 @@ export default function StopList() { { enableHighAccuracy: false, maximumAge: 5 * 60 * 1000, - }, + } ); }, []); @@ -117,7 +117,7 @@ export default function StopList() { lat1: number, lon1: number, lat2: number, - lon2: number, + lon2: number ) => { const R = 6371000; // meters const dLat = toRadians(lat2 - lat1); @@ -145,7 +145,7 @@ export default function StopList() { userLocation.latitude, userLocation.longitude, stop.latitude, - stop.longitude, + stop.longitude ); return { stop, distance }; @@ -183,7 +183,7 @@ export default function StopList() { // Update favourite and recent stops with full data const favStops = stopsWithFavourites.filter((stop) => - favouriteStopsIds.includes(stop.stopId), + favouriteStopsIds.includes(stop.stopId) ); setFavouriteStops(favStops); @@ -312,7 +312,7 @@ export default function StopList() { )} {!loading && data ? (userLocation ? sortedAllStops.slice(0, 6) : sortedAllStops).map( - (stop) => , + (stop) => ) : null} diff --git a/src/frontend/app/routes/map.tsx b/src/frontend/app/routes/map.tsx index d520e5a..5a8c7a2 100644 --- a/src/frontend/app/routes/map.tsx +++ b/src/frontend/app/routes/map.tsx @@ -172,7 +172,17 @@ export default function StopMap() { `stop-${region}-cancelled`, `stop-${region}`, ], - "icon-size": ["interpolate", ["linear"], ["zoom"], 13, 0.4, 14, 0.7, 18, 1.0], + "icon-size": [ + "interpolate", + ["linear"], + ["zoom"], + 13, + 0.4, + 14, + 0.7, + 18, + 1.0, + ], "icon-allow-overlap": true, "icon-ignore-placement": true, }} diff --git a/src/frontend/app/routes/settings.tsx b/src/frontend/app/routes/settings.tsx index d9c882d..2134b4c 100644 --- a/src/frontend/app/routes/settings.tsx +++ b/src/frontend/app/routes/settings.tsx @@ -127,7 +127,7 @@ export default function Settings() { e.target.value as | "regular" | "grouped" - | "experimental_consolidated", + | "experimental_consolidated" ) } > @@ -198,7 +198,7 @@ export default function Settings() {

{t( "about.region_change_message", - "¿Estás seguro de que quieres cambiar la región? Serás redirigido a la lista de paradas.", + "¿Estás seguro de que quieres cambiar la región? Serás redirigido a la lista de paradas." )}

diff --git a/src/frontend/app/routes/stops-$id.tsx b/src/frontend/app/routes/stops-$id.tsx index 6e669ca..ac41250 100644 --- a/src/frontend/app/routes/stops-$id.tsx +++ b/src/frontend/app/routes/stops-$id.tsx @@ -42,7 +42,7 @@ interface ErrorInfo { const loadConsolidatedData = async ( region: RegionId, - stopId: string, + stopId: string ): Promise => { const regionConfig = getRegionConfig(region); const resp = await fetch( @@ -51,7 +51,7 @@ const loadConsolidatedData = async ( headers: { Accept: "application/json", }, - }, + } ); if (!resp.ok) { @@ -151,7 +151,7 @@ export default function Estimates() { StopDataProvider.pushRecent(region, parseInt(params.id ?? "")); setFavourited( - StopDataProvider.isFavourite(region, parseInt(params.id ?? "")), + StopDataProvider.isFavourite(region, parseInt(params.id ?? "")) ); }, [params.id, region, loadData]); @@ -240,7 +240,7 @@ export default function Estimates() { onRetry={loadData} title={t( "errors.estimates_title", - "Error al cargar estimaciones", + "Error al cargar estimaciones" )} /> ) : data ? ( diff --git a/src/frontend/app/routes/timetable-$id.tsx b/src/frontend/app/routes/timetable-$id.tsx index da7a2e7..af5e42a 100644 --- a/src/frontend/app/routes/timetable-$id.tsx +++ b/src/frontend/app/routes/timetable-$id.tsx @@ -26,7 +26,7 @@ interface ErrorInfo { const loadTimetableData = async ( region: RegionId, - stopId: string, + stopId: string ): Promise => { const regionConfig = getRegionConfig(region); @@ -45,7 +45,7 @@ const loadTimetableData = async ( headers: { Accept: "application/json", }, - }, + } ); if (!resp.ok) { @@ -65,18 +65,18 @@ const timeToMinutes = (time: string): number => { const filterTimetableData = ( data: ScheduledTable[], currentTime: string, - showPast: boolean = false, + showPast: boolean = false ): ScheduledTable[] => { if (showPast) return data; const currentMinutes = timeToMinutes(currentTime); const sortedData = [...data].sort( - (a, b) => timeToMinutes(a.calling_time) - timeToMinutes(b.calling_time), + (a, b) => timeToMinutes(a.calling_time) - timeToMinutes(b.calling_time) ); // Find the current position const currentIndex = sortedData.findIndex( - (entry) => timeToMinutes(entry.calling_time) >= currentMinutes, + (entry) => timeToMinutes(entry.calling_time) >= currentMinutes ); if (currentIndex === -1) { @@ -161,7 +161,7 @@ export default function Timetable() { const filteredData = filterTimetableData( timetableData, currentTime, - showPastEntries, + showPastEntries ); const parseError = (error: any): ErrorInfo => { @@ -210,11 +210,11 @@ export default function Timetable() { const currentMinutes = timeToMinutes(currentTime); const sortedData = [...timetableBody].sort( (a, b) => - timeToMinutes(a.calling_time) - timeToMinutes(b.calling_time), + timeToMinutes(a.calling_time) - timeToMinutes(b.calling_time) ); const nextIndex = sortedData.findIndex( - (entry) => timeToMinutes(entry.calling_time) >= currentMinutes, + (entry) => timeToMinutes(entry.calling_time) >= currentMinutes ); if (nextIndex !== -1 && nextEntryRef.current) { @@ -293,13 +293,13 @@ export default function Timetable() {

{t( "timetable.noDataAvailable", - "No hay datos de horarios disponibles para hoy", + "No hay datos de horarios disponibles para hoy" )}

{t( "timetable.errorDetail", - "Los horarios teóricos se actualizan diariamente. Inténtalo más tarde.", + "Los horarios teóricos se actualizan diariamente. Inténtalo más tarde." )}

-- cgit v1.3