-
Notifications
You must be signed in to change notification settings - Fork 190
Expand file tree
/
Copy pathApp.tsx
More file actions
65 lines (56 loc) · 2.04 KB
/
App.tsx
File metadata and controls
65 lines (56 loc) · 2.04 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
64
65
import * as React from "react";
import { useEffect } from "react";
import Header from "./Components/Header/Header.tsx"; // Import Header
import "./Styles/App.css";
import HomePage from "./Pages/HomePage.tsx";
import DefaultPage from "./Pages/DefaultPage";
//import AuxiliaryPage from "./Pages/AuxiliaryPage/AuxiliaryPage.tsx";
import NotFound from "./Pages/NotFound.tsx";
import { ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
import {
HashRouter as Router,
Routes,
Route,
Navigate,
} from "react-router-dom";
import Spinner from "./Components/Spinner/Spinner.tsx";
import { useDispatch, useSelector, shallowEqual } from 'react-redux';
import { RootState } from './store';
type AppProps = {
isDarkMode: boolean; // Prop to control dark mode
toggleTheme: () => void; // Function to toggle dark mode
};
const App: React.FC<AppProps> = ({ isDarkMode, toggleTheme }) => {
const store = useSelector((state: RootState) => ({
loader: state.loader.loadingStack
}), shallowEqual);
// Apply or remove the "dark-mode" class on the body element based on isDarkMode
useEffect(() => {
if (isDarkMode) {
document.body.classList.add("dark-mode");
} else {
document.body.classList.remove("dark-mode");
}
}, [isDarkMode]);
return (
<div className="app-container">
<Spinner isLoading={store.loader.length > 0} label="please wait..." />
<Router>
<Header toggleTheme={toggleTheme} isDarkMode={isDarkMode} />
{/* Main Layout */}
<main>
<Routes>
<Route path="/" element={<Navigate to="/default" />} /> {/*Default route (i.e., landing page) */}
<Route path="/home" element={<HomePage />} />
<Route path="/default" element={<DefaultPage />} />
{/* <Route path="/auxiliary" element={<AuxiliaryPage />} /> */}
<Route path="*" element={<NotFound />} />
</Routes>
</main>
</Router>
<ToastContainer position="top-right" autoClose={3000} />
</div>
);
};
export default App;