From 80d64e04441ced7caecd238ae232e749d8e0dddf Mon Sep 17 00:00:00 2001
From: realtradam <github@tradam.dev>
Date: Tue, 21 May 2024 23:32:53 -0400
Subject: initial setup of seperating frontend

---
 src/routes/index.jsx | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 src/routes/index.jsx

(limited to 'src/routes/index.jsx')

diff --git a/src/routes/index.jsx b/src/routes/index.jsx
new file mode 100644
index 0000000..1b778ef
--- /dev/null
+++ b/src/routes/index.jsx
@@ -0,0 +1,35 @@
+import React, { useState, useEffect } from "react";
+import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
+import Home from "../components/Home";
+import Blogs from "../components/Blogs";
+import Games from "../components/Games";
+import Game from "../components/Game";
+import Layout from "../components/Layout";
+
+export default function index()
+{
+	const [userData, setUserData] = useState({});
+	const url = "/api/v1/auth/data";
+	useEffect(() => {
+		fetch(url).then((response) => {
+		if(response.ok) {
+			return response.json();
+		}
+		throw new Error("Network response was not ok.");
+	}).then((response) => setUserData(response.user_data));}, []);
+		// get user data here
+		// then pass it in as 'props' into the components
+	return (<>
+		{/*<h1>{userData.login}</h1>*/}
+		<Router>
+			<Routes>
+				<Route path="/" element = {<Layout userData={userData}/>}>
+					<Route index element={<Home />} />
+					<Route path="/blogs" element={<Blogs />} />
+					<Route path="/games" element={<Games />} />
+					<Route path="/games/:user/:game" element={<Game />} />
+				</Route>
+			</Routes>
+		</Router>
+	</>);
+}
-- 
cgit v1.2.3

