aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/app/components/RegularTable.tsx
diff options
context:
space:
mode:
authorAriel Costas Guerrero <ariel@costas.dev>2025-11-30 20:49:48 +0100
committerAriel Costas Guerrero <ariel@costas.dev>2025-11-30 20:49:48 +0100
commita68ba30716062b265f85c4be078a736c7135d7bc (patch)
treedd079a2d3860349402ad5b614659fedcb90c2b99 /src/frontend/app/components/RegularTable.tsx
parentcee521142a4e0673b155d97c3e4825b7fec1987f (diff)
Refactor StopMap and Settings components; replace region config usage with REGION_DATA, update StopDataProvider calls, and improve UI elements. Remove unused timetable files and add Tailwind CSS support.
Diffstat (limited to 'src/frontend/app/components/RegularTable.tsx')
-rw-r--r--src/frontend/app/components/RegularTable.tsx94
1 files changed, 0 insertions, 94 deletions
diff --git a/src/frontend/app/components/RegularTable.tsx b/src/frontend/app/components/RegularTable.tsx
deleted file mode 100644
index a738d03..0000000
--- a/src/frontend/app/components/RegularTable.tsx
+++ /dev/null
@@ -1,94 +0,0 @@
-import { useTranslation } from "react-i18next";
-import { type RegionConfig } from "../config/RegionConfig";
-import { type Estimate } from "../routes/estimates-$id";
-import LineIcon from "./LineIcon";
-
-interface RegularTableProps {
- data: Estimate[];
- dataDate: Date | null;
- regionConfig: RegionConfig;
-}
-
-export const RegularTable: React.FC<RegularTableProps> = ({
- data,
- dataDate,
- regionConfig,
-}) => {
- const { t } = useTranslation();
-
- 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")}`;
- }
- };
-
- return (
- <table className="table">
- <caption>
- {t("estimates.caption", "Estimaciones de llegadas a las {{time}}", {
- time: dataDate?.toLocaleTimeString(),
- })}
- </caption>
-
- <thead>
- <tr>
- <th>{t("estimates.line", "LĂ­nea")}</th>
- <th>{t("estimates.route", "Ruta")}</th>
- <th>{t("estimates.arrival", "Llegada")}</th>
- {regionConfig.showMeters && (
- <th>{t("estimates.distance", "Distancia")}</th>
- )}
- </tr>
- </thead>
-
- <tbody>
- {data
- .sort((a, b) => a.minutes - b.minutes)
- .map((estimate, idx) => (
- <tr key={idx}>
- <td>
- <LineIcon line={estimate.line} region={regionConfig.id} />
- </td>
- <td>{estimate.route}</td>
- <td>
- {estimate.minutes > 15
- ? absoluteArrivalTime(estimate.minutes)
- : `${estimate.minutes} ${t("estimates.minutes", "min")}`}
- </td>
- {regionConfig.showMeters && (
- <td>
- {estimate.meters > -1
- ? formatDistance(estimate.meters)
- : t("estimates.not_available", "No disponible")}
- </td>
- )}
- </tr>
- ))}
- </tbody>
-
- {data?.length === 0 && (
- <tfoot>
- <tr>
- <td colSpan={regionConfig.showMeters ? 4 : 3}>
- {t("estimates.none", "No hay estimaciones disponibles")}
- </td>
- </tr>
- </tfoot>
- )}
- </table>
- );
-};