-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.jsx
71 lines (58 loc) · 1.97 KB
/
App.jsx
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
64
65
66
67
68
69
70
71
import "./App.css";
import Homepage from "./pages/homepage";
import NavBar from "./components/navbar";
import Team from "./pages/team";
import Messages from "./pages/messages";
import Rota from "./pages/rota";
import { BrowserRouter, Routes, Route, useLocation } from "react-router-dom";
import RegisterEmployee from "./pages/register-employee";
import RegisterManager from "./pages/register-manager";
import RegisterCompany from "./pages/register-company";
import Login from "./pages/login";
import NotFound from "./pages/notfound";
import Footer from "./components/footer";
import { useDispatch, Provider } from "react-redux";
import { useEffect } from "react";
import { checkAuth } from "./features/user";
import { store } from "./store";
import Dashboard from "./pages/dashboard";
function App() {
return (
<Provider store={store}>
<BrowserRouter>
<AppContent />
</BrowserRouter>
</Provider>
);
}
function AppRoutes() {
const location = useLocation().pathname;
const locations = ["/team", "/rota", "/messages", "/dashboard"];
const showNavBar = !locations.includes(location);
return (
<>
{showNavBar && <NavBar />}
<Routes>
<Route path="/" element={<Homepage />} />
<Route path="/team" element={<Team />} />
<Route path="/messages" element={<Messages />} />
<Route path="/dashboard" element={<Dashboard />} />
<Route path="/rota" element={<Rota />} />
<Route path="/login" element={<Login />} />
<Route path="/register-employee" element={<RegisterEmployee />} />
<Route path="/register-employer" element={<RegisterManager />} />
<Route path="/register-company" element={<RegisterCompany />} />
<Route path="*" element={<NotFound />} />
</Routes>
{showNavBar && <Footer />}
</>
);
}
function AppContent() {
const dispatch = useDispatch();
useEffect(() => {
dispatch(checkAuth());
}, [dispatch]);
return <AppRoutes />;
}
export default App;