From 2656a9c1ed802f87d30530f6cea502a3238880de Mon Sep 17 00:00:00 2001
From: Ariel Costas Guerrero <94913521+arielcostas@users.noreply.github.com>
Date: Mon, 26 Aug 2024 00:12:23 +0200
Subject: Add simpleCSS, improve usability

---
 src/pages/Stop.tsx | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

(limited to 'src/pages/Stop.tsx')

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>
 		</>
 	)
 }
-- 
cgit v1.3

