Anding routing fixing bugs
This commit is contained in:
1 parent
69c24223ab
commit
5c31e38b2d
4 files changed
+132
-526
No files matched your search
Generated
+79
-514
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -27,7 +27,7 @@
|
||||
"react-dom": "^18.2.0",
|
||||
"react-redux": "9.1.2",
|
||||
"react-router": "^6.23.0",
|
||||
"react-router-dom": "^6.23.0"
|
||||
"react-router-dom": "^6.23.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.2.66",
|
||||
|
||||
@@ -6,6 +6,8 @@ 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 SettingsIcon from "../../assets/Images/Icon-setting-gray.png";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { useNavigate, useLocation } from "react-router-dom";
|
||||
|
||||
/**
|
||||
* @component
|
||||
@@ -16,13 +18,56 @@ import SettingsIcon from "../../assets/Images/Icon-setting-gray.png";
|
||||
*/
|
||||
|
||||
function DashboardMenu() {
|
||||
const [activeButton, setActiveButton] = useState(null);
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
||||
useEffect(() => {
|
||||
setActiveButton(location.pathname);
|
||||
}, [location]);
|
||||
|
||||
const handleClick = (title, path) => {
|
||||
setActiveButton(title);
|
||||
navigate(path);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="dashboard-menu-container">
|
||||
{DashboardMenuButton(Monitors, "Monitors", "/monitors")}
|
||||
{DashboardMenuButton(Incidents, "Incidents", "/incidents")}
|
||||
{DashboardMenuButton(SensorsIcon, "Status Pages", "/status")}
|
||||
{DashboardMenuButton(AllInclusiveIcon, "Integrations", "/integrations")}
|
||||
{DashboardMenuButton(SettingsIcon, "Settings", "/settings")}
|
||||
{DashboardMenuButton(
|
||||
Monitors,
|
||||
"Monitors",
|
||||
"/monitors",
|
||||
activeButton === "/monitors",
|
||||
() => handleClick("Monitors", "/monitors")
|
||||
)}
|
||||
{DashboardMenuButton(
|
||||
Incidents,
|
||||
"Incidents",
|
||||
"/incidents",
|
||||
activeButton === "/incidents",
|
||||
() => handleClick("Incidents", "/incidents")
|
||||
)}
|
||||
{DashboardMenuButton(
|
||||
SensorsIcon,
|
||||
"Status Pages",
|
||||
"/status",
|
||||
activeButton === "/status",
|
||||
() => handleClick("Status Pages", "/status")
|
||||
)}
|
||||
{DashboardMenuButton(
|
||||
AllInclusiveIcon,
|
||||
"Integrations",
|
||||
"/integrations",
|
||||
activeButton === "/integrations",
|
||||
() => handleClick("Integrations", "/integrations")
|
||||
)}
|
||||
{DashboardMenuButton(
|
||||
SettingsIcon,
|
||||
"Settings",
|
||||
"/settings",
|
||||
activeButton === "/settings",
|
||||
() => handleClick("Settings", "/settings")
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,13 +11,9 @@ import { useNavigate } from "react-router-dom";
|
||||
* @returns {React.ReactElement} The rendered menu button component.
|
||||
*/
|
||||
|
||||
const DashboardMenuButton = (icon, title, to) => {
|
||||
const [isActive, setIsActive] = useState(false);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const DashboardMenuButton = (icon, title, to, isActive, onClick) => {
|
||||
const handleClick = () => {
|
||||
setIsActive(!isActive);
|
||||
navigate(to);
|
||||
onClick();
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user