From ed023a4b5ee257c0c367357b6d83f9778e2cf536 Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero Date: Mon, 8 Dec 2025 12:40:49 +0100 Subject: fix: update default formatter to Prettier and enhance ETA display logic in ConsolidatedCirculationCard --- src/frontend/app/components/StopSummarySheet.tsx | 1 + .../Stops/ConsolidatedCirculationCard.tsx | 38 ++++++++++++++++++---- 2 files changed, 32 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/frontend/app/components/StopSummarySheet.tsx b/src/frontend/app/components/StopSummarySheet.tsx index 55cbbd8..c2d6ffe 100644 --- a/src/frontend/app/components/StopSummarySheet.tsx +++ b/src/frontend/app/components/StopSummarySheet.tsx @@ -158,6 +158,7 @@ export const StopSheet: React.FC = ({ ) : ( )} diff --git a/src/frontend/app/components/Stops/ConsolidatedCirculationCard.tsx b/src/frontend/app/components/Stops/ConsolidatedCirculationCard.tsx index 3fa984b..425cf7b 100644 --- a/src/frontend/app/components/Stops/ConsolidatedCirculationCard.tsx +++ b/src/frontend/app/components/Stops/ConsolidatedCirculationCard.tsx @@ -137,9 +137,31 @@ export const ConsolidatedCirculationCard: React.FC< const etaMinutes = estimate.realTime?.minutes ?? estimate.schedule?.minutes ?? null; - const etaValue = - etaMinutes === null ? "--" : Math.max(0, Math.round(etaMinutes)).toString(); - const etaUnit = t("estimates.minutes", "min"); + + let etaValue: string; + let etaUnit: string; + + if (etaMinutes === null) { + etaValue = "--"; + etaUnit = t("estimates.minutes", "min"); + } else { + const isRenfe = driver === "renfe"; + const isLongWait = etaMinutes > 60; + + if (isRenfe || isLongWait) { + const now = new Date(); + const arrivalTime = new Date(now.getTime() + etaMinutes * 60 * 1000); + etaValue = arrivalTime.toLocaleTimeString([], { + hour: "2-digit", + minute: "2-digit", + hour12: false, + }); + etaUnit = ""; + } else { + etaValue = Math.max(0, Math.round(etaMinutes)).toString(); + etaUnit = t("estimates.minutes", "min"); + } + } const timeClass = useMemo(() => { if (estimate.realTime && estimate.schedule?.running) { @@ -291,7 +313,7 @@ export const ConsolidatedCirculationCard: React.FC< `.trim()} {...interactiveProps} > -
+
@@ -301,7 +323,7 @@ export const ConsolidatedCirculationCard: React.FC< {estimate.schedule.tripId} )} - {estimate.route} + {driver === "renfe" ? estimate.route.toUpperCase() : estimate.route} {metaChips.length > 0 && (
@@ -395,13 +417,15 @@ export const ConsolidatedCirculationCard: React.FC<
- + {driver === "renfe" && estimate.schedule?.tripId && ( {estimate.schedule.tripId} )} - {estimate.route} + {driver === "renfe" + ? estimate.route.toUpperCase() + : estimate.route} {estimate.nextStreets && estimate.nextStreets.length > 0 && ( -- cgit v1.3