From 7b8594debceb93a1fa400d48fe1dcff943bd5af6 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Jun 2025 23:44:25 +0200 Subject: Implement stop sheet modal for map stop interactions (#27) 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/components/RegularTable.tsx | 129 +++++++++++++++------------ 1 file changed, 72 insertions(+), 57 deletions(-) (limited to 'src/frontend/app/components/RegularTable.tsx') diff --git a/src/frontend/app/components/RegularTable.tsx b/src/frontend/app/components/RegularTable.tsx index e5b3782..8b01410 100644 --- a/src/frontend/app/components/RegularTable.tsx +++ b/src/frontend/app/components/RegularTable.tsx @@ -3,70 +3,85 @@ import { type StopDetails } from "../routes/estimates-$id"; import LineIcon from "./LineIcon"; interface RegularTableProps { - data: StopDetails; - dataDate: Date | null; + data: StopDetails; + dataDate: Date | null; } -export const RegularTable: React.FC = ({ data, dataDate }) => { - const { t } = useTranslation(); +export const RegularTable: React.FC = ({ + data, + dataDate, +}) => { + const { t } = useTranslation(); - const absoluteArrivalTime = (minutes: number) => { - const now = new Date() - const arrival = new Date(now.getTime() + minutes * 60000) - return Intl.DateTimeFormat(navigator.language, { - hour: '2-digit', - minute: '2-digit' - }).format(arrival) - } + const absoluteArrivalTime = (minutes: number) => { + const now = new Date(); + const arrival = new Date(now.getTime() + minutes * 60000); + return Intl.DateTimeFormat( + typeof navigator !== "undefined" ? navigator.language : "en", + { + hour: "2-digit", + minute: "2-digit", + } + ).format(arrival); + }; - const formatDistance = (meters: number) => { - if (meters > 1024) { - return `${(meters / 1000).toFixed(1)} km`; - } else { - return `${meters} ${t('estimates.meters', 'm')}`; - } + const formatDistance = (meters: number) => { + if (meters > 1024) { + return `${(meters / 1000).toFixed(1)} km`; + } else { + return `${meters} ${t("estimates.meters", "m")}`; } + }; - return - + return ( +
{t('estimates.caption', 'Estimaciones de llegadas a las {{time}}', { time: dataDate?.toLocaleTimeString() })}
+ - - - - - - - - + + + + + + + + - - {data.estimates - .sort((a, b) => a.minutes - b.minutes) - .map((estimate, idx) => ( - - - - - - - ))} - + + {data.estimates + .sort((a, b) => a.minutes - b.minutes) + .map((estimate, idx) => ( + + + + + + + ))} + - {data?.estimates.length === 0 && ( - - - - - - )} + {data?.estimates.length === 0 && ( + + + + + + )}
+ {t("estimates.caption", "Estimaciones de llegadas a las {{time}}", { + time: dataDate?.toLocaleTimeString(), + })} +
{t('estimates.line', 'Línea')}{t('estimates.route', 'Ruta')}{t('estimates.arrival', 'Llegada')}{t('estimates.distance', 'Distancia')}
{t("estimates.line", "Línea")}{t("estimates.route", "Ruta")}{t("estimates.arrival", "Llegada")}{t("estimates.distance", "Distancia")}
{estimate.route} - {estimate.minutes > 15 - ? absoluteArrivalTime(estimate.minutes) - : `${estimate.minutes} ${t('estimates.minutes', 'min')}`} - - {estimate.meters > -1 - ? formatDistance(estimate.meters) - : t('estimates.not_available', 'No disponible') - } -
+ + {estimate.route} + {estimate.minutes > 15 + ? absoluteArrivalTime(estimate.minutes) + : `${estimate.minutes} ${t("estimates.minutes", "min")}`} + + {estimate.meters > -1 + ? formatDistance(estimate.meters) + : t("estimates.not_available", "No disponible")} +
{t('estimates.none', 'No hay estimaciones disponibles')}
+ {t("estimates.none", "No hay estimaciones disponibles")} +
-} + ); +}; -- cgit v1.3