diff options
| author | Ariel Costas Guerrero <94913521+arielcostas@users.noreply.github.com> | 2024-08-26 00:12:23 +0200 |
|---|---|---|
| committer | Ariel Costas Guerrero <94913521+arielcostas@users.noreply.github.com> | 2024-08-26 00:12:23 +0200 |
| commit | 2656a9c1ed802f87d30530f6cea502a3238880de (patch) | |
| tree | 1f5c28985eeb736b2bbcc7e2f0c5f1aeaf09410d /src/pages/Stop.tsx | |
| parent | 780aeaa93f458a399ecad771dd6ff7b7569bd2ff (diff) | |
Add simpleCSS, improve usability
Diffstat (limited to 'src/pages/Stop.tsx')
| -rw-r--r-- | src/pages/Stop.tsx | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/pages/Stop.tsx b/src/pages/Stop.tsx index 2ee077c..33f1a31 100644 --- a/src/pages/Stop.tsx +++ b/src/pages/Stop.tsx @@ -19,7 +19,7 @@ interface StopDetails { export function Stop(): JSX.Element { const params = useParams(); - const { data, error, isLoading } = useSWR<StopDetails>('home', async () => { + const { data, error, isLoading } = useSWR<StopDetails>(`stop-${params.stopId}`, async () => { let response; try { @@ -31,6 +31,15 @@ export function Stop(): JSX.Element { } }); + 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) + } + if (isLoading) return <h1>Loading...</h1> if (error) return <h1>Error: {JSON.stringify(error)}</h1> if (data === undefined) return <h1>No data</h1> @@ -58,12 +67,23 @@ export function Stop(): JSX.Element { <tr key={idx}> <td>{estimate.line}</td> <td>{estimate.route}</td> - <td>{estimate.minutes}</td> - <td>{estimate.meters}</td> + <td> + {estimate.minutes} ({absoluteArrivalTime(estimate.minutes)}) + </td> + <td> + {estimate.meters > -1 + ? `${estimate.meters} metros` + : "No disponible" + } + </td> </tr> ))} </tbody> </table> + + <p> + <a href="/">Volver al inicio</a> + </p> </> ) } |
