From bed48c3d7e49b1736d50ce42d92bb6c18cf02504 Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero Date: Mon, 22 Dec 2025 22:06:06 +0100 Subject: Refactor arrivals handling and improve type definitions; reorganise components --- .../app/components/arrivals/ArrivalCard.tsx | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/frontend/app/components/arrivals/ArrivalCard.tsx (limited to 'src/frontend/app/components/arrivals/ArrivalCard.tsx') diff --git a/src/frontend/app/components/arrivals/ArrivalCard.tsx b/src/frontend/app/components/arrivals/ArrivalCard.tsx new file mode 100644 index 0000000..de4fcc7 --- /dev/null +++ b/src/frontend/app/components/arrivals/ArrivalCard.tsx @@ -0,0 +1,74 @@ +import React, { useMemo } from "react"; +import { useTranslation } from "react-i18next"; +import LineIcon from "~/components/LineIcon"; +import { type Arrival } from "../../api/schema"; +import "./ArrivalCard.css"; + +interface ArrivalCardProps { + arrival: Arrival; + reduced?: boolean; +} + +export const ArrivalCard: React.FC = ({ + arrival, + reduced, +}) => { + const { t } = useTranslation(); + const { route, headsign, estimate } = arrival; + + const etaValue = estimate.minutes.toString(); + const etaUnit = t("estimates.minutes", "min"); + + const timeClass = useMemo(() => { + switch (estimate.precision) { + case "confident": + return "time-running"; + case "unsure": + return "time-delayed"; + case "past": + return "time-past"; + default: + return "time-scheduled"; + } + }, [estimate.precision]); + + return ( +
+
+ +
+
+ + {headsign.destination} + +
+
+
+ {etaValue} + + {etaUnit} + +
+
+
+ ); +}; -- cgit v1.3