From ee69c62adc5943a1dbd154df5142c0e726bdd317 Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero Date: Fri, 13 Mar 2026 16:49:10 +0100 Subject: feat(routes): add realtime estimates panel with pattern-aware styling - New GET /api/stops/estimates endpoint (nano mode: tripId, patternId, estimate, delay only) - useStopEstimates hook wiring estimates to routes-$id stop panel - Pattern-aware styling: dim schedules and estimates from other patterns - Past scheduled departures shown with strikethrough instead of hidden - Persist selected pattern in URL hash (replace navigation, no history push) - Fix planner arrivals using new estimates endpoint --- src/frontend/app/hooks/useArrivals.ts | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/frontend/app/hooks/useArrivals.ts') diff --git a/src/frontend/app/hooks/useArrivals.ts b/src/frontend/app/hooks/useArrivals.ts index e86a0bf..530ebc4 100644 --- a/src/frontend/app/hooks/useArrivals.ts +++ b/src/frontend/app/hooks/useArrivals.ts @@ -1,5 +1,5 @@ import { useQuery } from "@tanstack/react-query"; -import { fetchArrivals } from "../api/arrivals"; +import { fetchArrivals, fetchEstimates } from "../api/arrivals"; export const useStopArrivals = ( stopId: string, @@ -10,7 +10,22 @@ export const useStopArrivals = ( queryKey: ["arrivals", stopId, reduced], queryFn: () => fetchArrivals(stopId, reduced), enabled: !!stopId && enabled, - refetchInterval: 15000, // Refresh every 15 seconds - retry: false, // Disable retries to see errors immediately + refetchInterval: 15000, + retry: false, + }); +}; + +export const useStopEstimates = ( + stopId: string, + routeId: string, + viaStopId?: string, + enabled: boolean = true +) => { + return useQuery({ + queryKey: ["estimates", stopId, routeId, viaStopId], + queryFn: () => fetchEstimates(stopId, routeId, viaStopId), + enabled: !!stopId && !!routeId && enabled, + refetchInterval: 15000, + retry: false, }); }; -- cgit v1.3