Spaces:
Running
Running
Create App.jsx
Browse files
App.jsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from "react";
|
| 2 |
+
import { BrowserRouter as Router, Route, Routes, Navigate } from "react-router-dom";
|
| 3 |
+
import AuthForm from "./components/AuthForm";
|
| 4 |
+
import SearchPage from "./pages/SearchPage";
|
| 5 |
+
|
| 6 |
+
const App = () => {
|
| 7 |
+
const token = localStorage.getItem("token");
|
| 8 |
+
return (
|
| 9 |
+
<Router>
|
| 10 |
+
<Routes>
|
| 11 |
+
<Route path="/login" element={<AuthForm type="login" />} />
|
| 12 |
+
<Route path="/signup" element={<AuthForm type="signup" />} />
|
| 13 |
+
<Route path="/search" element={token ? <SearchPage /> : <Navigate to="/login" />} />
|
| 14 |
+
<Route path="*" element={<Navigate to="/login" />} />
|
| 15 |
+
</Routes>
|
| 16 |
+
</Router>
|
| 17 |
+
);
|
| 18 |
+
};
|
| 19 |
+
|
| 20 |
+
export default App;
|