-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
37 lines (34 loc) · 981 Bytes
/
Copy pathApp.js
File metadata and controls
37 lines (34 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { Routes, Route, Navigate } from "react-router-dom";
import Footer from "./components/Footer";
import Navbar from "./components/Navbar";
import Home from "./pages/Home";
import Login from "./pages/Login";
import Signup from "./pages/Signup";
import { useAuthContext } from "./hooks/useAuthContext";
function App() {
const { user } = useAuthContext();
return (
<>
<div className="app min-h-screen bg-slate-900 text-slate-50">
<Navbar />
<Routes>
<Route
path="/"
element={user ? <Home /> : <Navigate to="/login" />}
/>
<Route
path="/login"
element={!user ? <Login /> : <Navigate to="/" />}
/>
<Route
path="/signup"
element={!user ? <Signup /> : <Navigate to="/" />}
/>
<Route path="*" element={<Navigate to="/" />} />
</Routes>
</div>
<Footer />
</>
);
}
export default App;