From de6c4d9c3ea7ae1ad2babcb1a5518a5454eddc45 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Thu, 22 Jan 2026 22:05:18 +0000 Subject: [PATCH] remove extra network request --- .../IncidentTable/IncidentActionsMenu.jsx | 18 +++++++++--------- .../Components/IncidentTable/index.jsx | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/client/src/Pages/Incidents/Components/IncidentTable/IncidentActionsMenu.jsx b/client/src/Pages/Incidents/Components/IncidentTable/IncidentActionsMenu.jsx index 28b3a4f52..53b0adb11 100644 --- a/client/src/Pages/Incidents/Components/IncidentTable/IncidentActionsMenu.jsx +++ b/client/src/Pages/Incidents/Components/IncidentTable/IncidentActionsMenu.jsx @@ -4,7 +4,6 @@ import Menu from "@mui/material/Menu"; import MenuItem from "@mui/material/MenuItem"; import Icon from "@/Components/v1/Icon/index.jsx"; import ResolveIncidentDialog from "../ResolveIncidentDialog/index.jsx"; -import useFetchIncidents from "../../hooks/useFetchIncidents"; // Utils import { useState } from "react"; @@ -14,12 +13,11 @@ import { TypeToPathMap } from "@/Utils/monitorUtils.js"; import { useNavigate } from "react-router-dom"; import PropTypes from "prop-types"; -const IncidentActionsMenu = ({ incident, onResolve, onOpenDetails }) => { +const IncidentActionsMenu = ({ incident, monitor, onResolve, onOpenDetails }) => { const [anchorEl, setAnchorEl] = useState(null); const [isDialogOpen, setIsDialogOpen] = useState(false); const theme = useTheme(); const { t } = useTranslation(); - const { fetchIncidentById } = useFetchIncidents(); const navigate = useNavigate(); const openMenu = (event) => { event.preventDefault(); @@ -59,12 +57,10 @@ const IncidentActionsMenu = ({ incident, onResolve, onOpenDetails }) => { e.stopPropagation(); closeMenu(e); try { - const incidentData = await fetchIncidentById(incident.id); - if (incidentData) { - const { type, _id: monitorId } = incidentData.monitorId; - const path = TypeToPathMap[type]; - if (path && monitorId) { - navigate(`/${path}/${monitorId}`); + if (monitor) { + const path = TypeToPathMap[monitor.type]; + if (path && monitor.id) { + navigate(`/${path}/${monitor.id}`); } else { console.error(`Monitor type not found`); } @@ -149,6 +145,10 @@ IncidentActionsMenu.propTypes = { id: PropTypes.string.isRequired, status: PropTypes.bool.isRequired, }).isRequired, + monitor: PropTypes.shape({ + id: PropTypes.string.isRequired, + type: PropTypes.string.isRequired, + }).isRequired, onResolve: PropTypes.func.isRequired, onOpenDetails: PropTypes.func, }; diff --git a/client/src/Pages/Incidents/Components/IncidentTable/index.jsx b/client/src/Pages/Incidents/Components/IncidentTable/index.jsx index 7d23d8ebd..05242c1f3 100644 --- a/client/src/Pages/Incidents/Components/IncidentTable/index.jsx +++ b/client/src/Pages/Incidents/Components/IncidentTable/index.jsx @@ -129,6 +129,7 @@ const IncidentTable = ({ return ( monitor.id === row.monitorId)} onResolve={handleResolveIncident} onOpenDetails={onOpenDetails} />