From f942f8df78a97d302d4ccca8a87e8a410f845dbe Mon Sep 17 00:00:00 2001
From: Ariel Costas Guerrero <94913521+arielcostas@users.noreply.github.com>
Date: Mon, 9 Sep 2024 18:56:46 +0200
Subject: Add recent stop list

---
 src/pages/Home.tsx | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

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

diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx
index 1f5c319..568b2f0 100644
--- a/src/pages/Home.tsx
+++ b/src/pages/Home.tsx
@@ -28,6 +28,14 @@ export function Home() {
 		return data?.filter(stop => stop.favourite) ?? []
 	}, [data])
 
+	const recentStops = useMemo(() => {
+		const recent = sdp.getRecent();
+
+		if (recent.length === 0) return null;
+		
+		return recent.map(stopId => data?.find(stop => stop.stopId === stopId) as Stop).reverse();
+	}, [data])
+
 	if (data === null) return <h1>Loading...</h1>
 
 	return (
@@ -63,6 +71,18 @@ export function Home() {
 				))}
 			</ul>
 
+			<h2>Recientes</h2>
+
+			<ul>
+				{recentStops?.map((stop: Stop) => (
+					<li key={stop.stopId}>
+						<Link to={`/${stop.stopId}`}>
+							({stop.stopId}) {stop.name} - {stop.lines?.join(', ')}
+						</Link>
+					</li>
+				))}
+			</ul>
+
 			<h2>Paradas</h2>
 
 			<ul>
-- 
cgit v1.3

