From 3902da1747a3e32db0b67f1162eafd4860b3d27a Mon Sep 17 00:00:00 2001
From: Joseph Ditton <jditton.atomic@gmail.com>
Date: Sat, 20 Nov 2021 19:34:10 -0700
Subject: working on signup implementation

---
 client/components/router.jsx | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

(limited to 'client/components/router.jsx')

diff --git a/client/components/router.jsx b/client/components/router.jsx
index a40b06e..6760bea 100644
--- a/client/components/router.jsx
+++ b/client/components/router.jsx
@@ -1,10 +1,21 @@
-import { Routes, Route } from 'react-router-dom';
+import { useContext } from 'react';
+import { Routes, Route, Navigate } from 'react-router-dom';
 import { Home } from './home/_home';
+import { SettingsContext } from '../utils/settings_context';
+import { SignIn } from './sign_in/_sign_in';
+import { SignUp } from './sign_up/_sign_up';
 
 export const Router = () => {
+  const [settings] = useContext(SettingsContext);
+  const { JWT } = settings;
   return (
     <Routes>
-      <Route path="/" element={<Home />} />
+      <Route
+        path="/"
+        element={JWT ? <Home /> : <Navigate replace to="signin" />} // no JWT means not logged in
+      />
+      <Route path="signin" element={<SignIn />} />
+      <Route path="signup" element={<SignUp />} />
     </Routes>
   );
 };
-- 
cgit v1.2.3-70-g09d2

