From 75456baef54180539bacdf960258c6b1f20290eb Mon Sep 17 00:00:00 2001 From: Steve White Date: Sat, 12 Oct 2024 11:08:19 -0500 Subject: [PATCH] send user to /login if they don't have a token --- src/App.js | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/App.js b/src/App.js index e101522..f6b7715 100644 --- a/src/App.js +++ b/src/App.js @@ -1,6 +1,6 @@ // src/App.js import React, { useState, useEffect } from 'react'; -import { BrowserRouter as Router, Route, Routes } from 'react-router-dom'; +import { BrowserRouter as Router, Route, Routes, Navigate } from 'react-router-dom'; import { useParams } from 'react-router-dom'; import Login from './components/Login'; import Boxes from './components/Boxes'; @@ -15,17 +15,37 @@ function App() { localStorage.setItem('token', token); } }, [token]); + return ( - - - } /> - } /> - } /> - } /> - + ); } +function AppRoutes({ token, setToken }) { + const { id } = useParams(); // Move useParams here + + return ( + <> + + + } /> + : } + /> + : } + /> + : } + /> + } /> + + + ); +} export default App; \ No newline at end of file