aboutsummaryrefslogtreecommitdiff
path: root/src/pages
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages')
-rw-r--r--src/pages/Home.tsx20
-rw-r--r--src/pages/Stop.tsx2
2 files changed, 22 insertions, 0 deletions
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>
diff --git a/src/pages/Stop.tsx b/src/pages/Stop.tsx
index 4fa68cf..feb11b4 100644
--- a/src/pages/Stop.tsx
+++ b/src/pages/Stop.tsx
@@ -32,6 +32,8 @@ export function Stop(): JSX.Element {
useEffect(() => {
loadData();
+ sdp.pushRecent(parseInt(params.stopId ?? ""));
+
setFavourited(
sdp.isFavourite(parseInt(params.stopId ?? ""))
);