aboutsummaryrefslogtreecommitdiff
path: root/src/components/GroupedTable.tsx
diff options
context:
space:
mode:
authorAriel Costas Guerrero <ariel@costas.dev>2025-05-26 10:48:43 +0200
committerAriel Costas Guerrero <ariel@costas.dev>2025-05-26 10:48:43 +0200
commit5ced7f916d94e86e9a7ec164bee56f9a8e3a2a3a (patch)
treeb1ef5afa17b4a2f9fb2cbd683afc2fb6d905b5e1 /src/components/GroupedTable.tsx
parent4637373b50636e78dc2c7b6f99be879edb4ff7dc (diff)
Replace Azure SWA with custom server
Diffstat (limited to 'src/components/GroupedTable.tsx')
-rw-r--r--src/components/GroupedTable.tsx74
1 files changed, 0 insertions, 74 deletions
diff --git a/src/components/GroupedTable.tsx b/src/components/GroupedTable.tsx
deleted file mode 100644
index 58bb5ed..0000000
--- a/src/components/GroupedTable.tsx
+++ /dev/null
@@ -1,74 +0,0 @@
-import { StopDetails } from "../pages/Estimates";
-import LineIcon from "./LineIcon";
-
-interface GroupedTable {
- data: StopDetails;
- dataDate: Date | null;
-}
-
-export const GroupedTable: React.FC<GroupedTable> = ({ data, dataDate }) => {
- const formatDistance = (meters: number) => {
- if (meters > 1024) {
- return `${(meters / 1000).toFixed(1)} km`;
- } else {
- return `${meters} m`;
- }
- }
-
- const groupedEstimates = data.estimates.reduce((acc, estimate) => {
- if (!acc[estimate.line]) {
- acc[estimate.line] = [];
- }
- acc[estimate.line].push(estimate);
- return acc;
- }, {} as Record<string, typeof data.estimates>);
-
- const sortedLines = Object.keys(groupedEstimates).sort((a, b) => {
- const firstArrivalA = groupedEstimates[a][0].minutes;
- const firstArrivalB = groupedEstimates[b][0].minutes;
- return firstArrivalA - firstArrivalB;
- });
-
- return <table className="table">
- <caption>Estimaciones de llegadas a las {dataDate?.toLocaleTimeString()}</caption>
-
- <thead>
- <tr>
- <th>LĂ­nea</th>
- <th>Ruta</th>
- <th>Llegada</th>
- <th>Distancia</th>
- </tr>
- </thead>
-
- <tbody>
- {sortedLines.map((line) => (
- groupedEstimates[line].map((estimate, idx) => (
- <tr key={`${line}-${idx}`}>
- {idx === 0 && (
- <td rowSpan={groupedEstimates[line].length}>
- <LineIcon line={line} />
- </td>
- )}
- <td>{estimate.route}</td>
- <td>{`${estimate.minutes} min`}</td>
- <td>
- {estimate.meters > -1
- ? formatDistance(estimate.meters)
- : "No disponible"
- }
- </td>
- </tr>
- ))
- ))}
- </tbody>
-
- {data?.estimates.length === 0 && (
- <tfoot>
- <tr>
- <td colSpan={4}>No hay estimaciones disponibles</td>
- </tr>
- </tfoot>
- )}
- </table>
-} \ No newline at end of file