diff --git a/src/App.jsx b/src/App.jsx index 06156ab..1ffe70c 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -3,6 +3,8 @@ import Home from "./pages/Home"; import Sidebar from "./Sidebar"; import "./styles/style.css"; import Settings from "./pages/Settings"; +import Monitoring from "./pages/Monitoring"; +import Certification from "./pages/Certifiaction"; export default function App() { return ( @@ -13,6 +15,8 @@ export default function App() { } /> } /> + } /> + } /> diff --git a/src/Sidebar.jsx b/src/Sidebar.jsx index e733e30..400c232 100644 --- a/src/Sidebar.jsx +++ b/src/Sidebar.jsx @@ -1,4 +1,4 @@ -import { Link } from "react-router-dom"; +import { Link, useLocation } from "react-router-dom"; import MenuIcon from "./assets/menu_icon.svg?react"; import HomeIcon from "./assets/home_icon.svg?react"; import MonitorIcon from "./assets/monitor_icon.svg?react"; @@ -7,12 +7,23 @@ import AwardIcon from "./assets/award_icon.svg?react"; import BellIcon from "./assets/bell_icon.svg?react"; import CloseIcon from "./assets/close_icon.svg?react"; import Logo from "./assets/temp_logo.svg?react"; -import { useRef, useState } from "react"; +import { useEffect, useRef, useState } from "react"; export default function Sidebar() { - const [isOpen, setIsOpen] = useState(false); + const [isOpen, setIsOpen] = useState(true); const alram_count = 3; + const location = useLocation(); const [currentPage, setCurrentPage] = useState("Home"); + useEffect(() => { + if (location.pathname === "/") setCurrentPage("Home"); + else if (location.pathname.startsWith("/monitoring")) + setCurrentPage("Monitor"); + else if (location.pathname.startsWith("/settings")) + setCurrentPage("Sensor"); + else if (location.pathname.startsWith("/certification")) + setCurrentPage("Certification"); + }, [location.pathname]); + return (