diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2025-11-30 20:49:48 +0100 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2025-11-30 20:49:48 +0100 |
| commit | a68ba30716062b265f85c4be078a736c7135d7bc (patch) | |
| tree | dd079a2d3860349402ad5b614659fedcb90c2b99 /src/frontend/app/components/GroupedTable.tsx | |
| parent | cee521142a4e0673b155d97c3e4825b7fec1987f (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/GroupedTable.tsx')
| -rw-r--r-- | src/frontend/app/components/GroupedTable.tsx | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/src/frontend/app/components/GroupedTable.tsx b/src/frontend/app/components/GroupedTable.tsx deleted file mode 100644 index 175899a..0000000 --- a/src/frontend/app/components/GroupedTable.tsx +++ /dev/null @@ -1,90 +0,0 @@ -import { type RegionConfig } from "../config/RegionConfig"; -import { type Estimate } from "../routes/estimates-$id"; -import LineIcon from "./LineIcon"; - -interface GroupedTable { - data: Estimate[]; - dataDate: Date | null; - regionConfig: RegionConfig; -} - -export const GroupedTable: React.FC<GroupedTable> = ({ - data, - dataDate, - regionConfig, -}) => { - const formatDistance = (meters: number) => { - if (meters > 1024) { - return `${(meters / 1000).toFixed(1)} km`; - } else { - return `${meters} m`; - } - }; - - const groupedEstimates = data.reduce( - (acc, estimate) => { - if (!acc[estimate.line]) { - acc[estimate.line] = []; - } - acc[estimate.line].push(estimate); - return acc; - }, - {} as Record<string, typeof data> - ); - - 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> - {regionConfig.showMeters && <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} region={regionConfig.id} /> - </td> - )} - <td>{estimate.route}</td> - <td>{`${estimate.minutes} min`}</td> - {regionConfig.showMeters && ( - <td> - {estimate.meters > -1 - ? formatDistance(estimate.meters) - : "No disponible"} - </td> - )} - </tr> - )) - )} - </tbody> - - {data?.length === 0 && ( - <tfoot> - <tr> - <td colSpan={regionConfig.showMeters ? 4 : 3}> - No hay estimaciones disponibles - </td> - </tr> - </tfoot> - )} - </table> - ); -}; |
