remove extra network request

This commit is contained in:
Alex Holliday committed 2026-01-22 22:05:18 +00:00
1 parent 3339b6b67f
commit de6c4d9c3e
2 files changed
+10 -9

No files matched your search

@@ -4,7 +4,6 @@ import Menu from "@mui/material/Menu";
import MenuItem from "@mui/material/MenuItem"; import MenuItem from "@mui/material/MenuItem";
import Icon from "@/Components/v1/Icon/index.jsx"; import Icon from "@/Components/v1/Icon/index.jsx";
import ResolveIncidentDialog from "../ResolveIncidentDialog/index.jsx"; import ResolveIncidentDialog from "../ResolveIncidentDialog/index.jsx";
import useFetchIncidents from "../../hooks/useFetchIncidents";
// Utils // Utils
import { useState } from "react"; import { useState } from "react";
@@ -14,12 +13,11 @@ import { TypeToPathMap } from "@/Utils/monitorUtils.js";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
const IncidentActionsMenu = ({ incident, onResolve, onOpenDetails }) => { const IncidentActionsMenu = ({ incident, monitor, onResolve, onOpenDetails }) => {
const [anchorEl, setAnchorEl] = useState(null); const [anchorEl, setAnchorEl] = useState(null);
const [isDialogOpen, setIsDialogOpen] = useState(false); const [isDialogOpen, setIsDialogOpen] = useState(false);
const theme = useTheme(); const theme = useTheme();
const { t } = useTranslation(); const { t } = useTranslation();
const { fetchIncidentById } = useFetchIncidents();
const navigate = useNavigate(); const navigate = useNavigate();
const openMenu = (event) => { const openMenu = (event) => {
event.preventDefault(); event.preventDefault();
@@ -59,12 +57,10 @@ const IncidentActionsMenu = ({ incident, onResolve, onOpenDetails }) => {
e.stopPropagation(); e.stopPropagation();
closeMenu(e); closeMenu(e);
try { try {
const incidentData = await fetchIncidentById(incident.id); if (monitor) {
if (incidentData) { const path = TypeToPathMap[monitor.type];
const { type, _id: monitorId } = incidentData.monitorId; if (path && monitor.id) {
const path = TypeToPathMap[type]; navigate(`/${path}/${monitor.id}`);
if (path && monitorId) {
navigate(`/${path}/${monitorId}`);
} else { } else {
console.error(`Monitor type not found`); console.error(`Monitor type not found`);
} }
@@ -149,6 +145,10 @@ IncidentActionsMenu.propTypes = {
id: PropTypes.string.isRequired, id: PropTypes.string.isRequired,
status: PropTypes.bool.isRequired, status: PropTypes.bool.isRequired,
}).isRequired, }).isRequired,
monitor: PropTypes.shape({
id: PropTypes.string.isRequired,
type: PropTypes.string.isRequired,
}).isRequired,
onResolve: PropTypes.func.isRequired, onResolve: PropTypes.func.isRequired,
onOpenDetails: PropTypes.func, onOpenDetails: PropTypes.func,
}; };
@@ -129,6 +129,7 @@ const IncidentTable = ({
return ( return (
<IncidentActionsMenu <IncidentActionsMenu
incident={row} incident={row}
monitor={monitors.find((monitor) => monitor.id === row.monitorId)}
onResolve={handleResolveIncident} onResolve={handleResolveIncident}
onOpenDetails={onOpenDetails} onOpenDetails={onOpenDetails}
/> />