import { BasePage, StatBox } from "@/components/design-elements"; import ResolutionCard from "@/components/design-elements/ResolutionCard"; import Stack from "@mui/material/Stack"; import Typography from "@mui/material/Typography"; import { useTheme } from "@mui/material/styles"; import { useNavigate, useParams } from "react-router"; import { useGet } from "@/hooks/UseApi"; import type { ApiResponse } from "@/types/api"; import type { IIncident } from "@/types/incident"; import { formatDateWithTz } from "@/utils/TimeUtils"; import { useAppSelector } from "@/hooks/AppHooks"; import prettyMilliseconds from "pretty-ms"; import { getMonitorPath } from "@/utils/MonitorUtils"; import type { MonitorType } from "@/types/monitor"; import { useTranslation } from "react-i18next"; const IncidentDetailsPage = () => { const theme = useTheme(); const { t } = useTranslation(); const { id } = useParams<{ id: string }>(); const uiTimezone = useAppSelector((state: any) => state.ui.timezone); const navigate = useNavigate(); const { response } = useGet>(`/incidents/${id}`); const incident = response?.data || null; if (!incident) { return null; } const startMs = new Date(incident.startedAt).getTime(); const endMs = incident.endedAt ? new Date(incident.endedAt).getTime() : Date.now(); const duration = Math.max(0, endMs - startMs); return ( {t("incidents.title")} { const type = incident.monitorId.type as MonitorType; const path = getMonitorPath(type); const id = (incident.monitorId as any)?._id; if (id) navigate(`/${path}/${id}`); }} /> ); }; export default IncidentDetailsPage;