-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.jsx
More file actions
63 lines (58 loc) · 1.97 KB
/
Main.jsx
File metadata and controls
63 lines (58 loc) · 1.97 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import React, { Children } from "react";
import {
BrowserRouter as Router,
Route,
Routes,
useNavigate,
Navigate,
} from "react-router-dom";
import Navigation from "./components/Navigation";
import Home from "./pages/Home";
import About from "./pages/About";
import Contacts from "./pages/Contacts";
import NotFoundPage from "./pages/NotFoundPage";
import UserPage from "./pages/UserPage";
import Dashboard from "./pages/Dashboard";
import DashboardProfile from "./pages/DashboardProfile";
import DashboardSettings from "./pages/DashboardSettings";
import Profile from "./pages/Profile";
import Login from "./pages/Login";
import Products from "./pages/Products";
const Main = () => {
const loggedIn = false;
const PrivateProfile = ({ children }) => {
if (loggedIn) {
return children;
} else {
return <Navigate to={"/login"} />;
}
};
return (
<Router>
<Navigation />
<Routes>
<Route path="/" element={<Home />} />
<Route path="/about" element={<About />} />
<Route path="/contacts" element={<Contacts />} />
<Route path="/dashboard" element={<Dashboard />}>
<Route path="profile" element={<DashboardProfile />} />
<Route path="settings" element={<DashboardSettings />} />
</Route>
<Route path="/user/:id" element={<UserPage />} />
<Route
path="/profile"
element={
<PrivateProfile>
<Profile />
</PrivateProfile>
}
/>
<Route path="/login" element={<Login />} />
<Route path={"/products"} element={<Products />} />
<Route path="*" element={<NotFoundPage />} />
</Routes>
</Router>
);
};
export default Main;
//useSearchParams