Files
Checkmate/Client/src/Components/DashboardMenu/index.jsx
T

84 lines
2.5 KiB
React
Raw Normal View History

2024-06-06 12:27:36 +03:30
import "./index.css";
import DashboardMenuButton from "../DashboardMenuButton";
import Monitors from "../../assets/Images/Icon-monitor-gray.png";
import Incidents from "../../assets/Images/Icon-warning-gray.png";
import SensorsIcon from "../../assets/Images/Icon-signal-gray.png";
import AllInclusiveIcon from "../../assets/Images/Icon-link-gray.png";
import MaintenanceIcon from "../../assets/Images/Icon-maintenance-gray.png";
2024-06-06 12:27:36 +03:30
import SettingsIcon from "../../assets/Images/Icon-setting-gray.png";
2024-06-09 22:48:14 +03:30
import React, { useState, useEffect } from "react";
import { useNavigate, useLocation } from "react-router-dom";
2024-06-10 21:31:40 +03:30
import pathMap from "../../Utils/PathMap";
2024-05-13 16:12:20 -07:00
/**
2024-05-14 10:00:52 -07:00
* @component
2024-05-13 16:12:20 -07:00
* DashboardMenu component displays a menu with icons and corresponding text.
* Each menu item consists of an icon and a text label.
2024-06-06 12:27:36 +03:30
*
2024-05-13 16:12:20 -07:00
* @returns {JSX.Element} The JSX element representing the DashboardMenu component.
*/
function DashboardMenu() {
2024-06-09 22:48:14 +03:30
const [activeButton, setActiveButton] = useState(null);
const navigate = useNavigate();
const location = useLocation();
useEffect(() => {
setActiveButton(location.pathname);
}, [location]);
const handleClick = (title, path) => {
setActiveButton(title);
navigate(path);
};
2024-05-13 16:12:20 -07:00
return (
2024-06-06 12:27:36 +03:30
<div className="dashboard-menu-container">
2024-06-09 22:48:14 +03:30
{DashboardMenuButton(
Monitors,
"Monitors",
"/monitors",
activeButton === "/monitors",
2024-06-10 21:31:40 +03:30
() => handleClick(pathMap["/monitors"], "/monitors")
2024-06-09 22:48:14 +03:30
)}
{DashboardMenuButton(
Incidents,
"Incidents",
"/incidents",
activeButton === "/incidents",
2024-06-10 21:31:40 +03:30
() => handleClick(pathMap["/incidents"], "/incidents")
2024-06-09 22:48:14 +03:30
)}
{DashboardMenuButton(
SensorsIcon,
"Status Pages",
"/status",
activeButton === "/status",
2024-06-10 21:31:40 +03:30
() => handleClick(pathMap["/status"], "/status")
2024-06-09 22:48:14 +03:30
)}
{DashboardMenuButton(
AllInclusiveIcon,
"Integrations",
"/integrations",
activeButton === "/integrations",
2024-06-10 21:31:40 +03:30
() => handleClick(pathMap["/integrations"], "/integrations")
2024-06-09 22:48:14 +03:30
)}
{DashboardMenuButton(
MaintenanceIcon,
"Maintenance",
"/maintenance",
activeButton === "/maintenance",
() => handleClick(pathMap["/maintenance"], "/maintenance")
)}
2024-06-09 22:48:14 +03:30
{DashboardMenuButton(
SettingsIcon,
"Settings",
"/settings",
activeButton === "/settings",
2024-06-10 21:31:40 +03:30
() => handleClick(pathMap["/settings"], "/settings")
2024-06-09 22:48:14 +03:30
)}
2024-05-13 16:12:20 -07:00
</div>
);
}
export default DashboardMenu;