From dc20c2ba8377a90a3170642c9b3df6cd5166ad72 Mon Sep 17 00:00:00 2001
From: Ariel Costas Guerrero <94913521+arielcostas@users.noreply.github.com>
Date: Sun, 25 Aug 2024 23:12:48 +0200
Subject: Initial commit

---
 src/pages/Home.tsx | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 src/pages/Home.tsx

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

diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx
new file mode 100644
index 0000000..79f1ec2
--- /dev/null
+++ b/src/pages/Home.tsx
@@ -0,0 +1,33 @@
+import useSWR from "swr";
+
+interface Stop {
+	stopId: number
+	name: string;
+	latitude?: number;
+	longitude?: number;
+	lines: string[];
+}
+
+export function Home() {
+	const { data, error, isLoading } = useSWR<Stop[]>('home', async () => {
+		const response = await fetch('/api/ListStops')
+		return response.json()
+	});
+
+	if (isLoading) return <h1>Loading...</h1>
+	if (error) return <h1>Error</h1>
+
+	return (
+		<>
+			<h1>Home</h1>
+
+			<ul>
+				{data?.map((stop: Stop) => (
+					<li key={stop.stopId}>
+						{stop.name} - {stop.lines?.join(', ')}
+					</li>
+				))}
+			</ul>
+		</>
+	)
+}
-- 
cgit v1.3

