Files
Checkmate/client/src/Pages/Incidents/Components/CardDetails.tsx
T

202 lines
5.5 KiB
TypeScript
Raw Normal View History

2026-02-01 00:34:48 +00:00
import Stack from "@mui/material/Stack";
import Grid from "@mui/material/Grid";
import Divider from "@mui/material/Divider";
import Typography from "@mui/material/Typography";
2026-02-20 18:13:39 +00:00
import { BaseBox, ValueLabel } from "@/Components/design-elements";
2026-02-28 21:27:33 +00:00
import { LAYOUT } from "@/Utils/Theme/constants";
2026-02-01 00:34:48 +00:00
import { useTranslation } from "react-i18next";
import type { Incident } from "@/Types/Incident";
2026-02-01 00:49:35 +00:00
import type { Monitor } from "@/Types/Monitor";
2026-02-01 00:34:48 +00:00
import { useTheme } from "@mui/material";
2026-02-01 01:54:18 +00:00
import { useSelector } from "react-redux";
import type { RootState } from "@/Types/state";
import { formatDateWithTz } from "@/Utils/TimeUtils";
import { getIncidentsDuration } from "@/Pages/Incidents/utils";
2026-02-01 00:34:48 +00:00
interface CardDetailsProps {
incident: Incident | null;
monitor: Monitor | null;
2026-02-01 00:49:35 +00:00
sx?: object;
2026-02-01 00:34:48 +00:00
}
2026-04-29 09:56:01 -07:00
const SectionHeading = ({ children }: { children: React.ReactNode }) => {
const theme = useTheme();
return (
<Typography
component="h2"
variant="eyebrow"
color={theme.palette.text.secondary}
>
{children}
</Typography>
);
};
const Cell = ({ children }: { children: React.ReactNode }) => (
<Typography variant="body1">{children}</Typography>
);
2026-02-01 00:34:48 +00:00
export const CardDetails = ({ incident, monitor, sx }: CardDetailsProps) => {
const { t } = useTranslation();
const theme = useTheme();
2026-02-01 01:54:18 +00:00
const uiTimezone = useSelector((state: RootState) => state.ui.timezone);
2026-02-01 00:49:35 +00:00
2026-02-01 00:34:48 +00:00
if (!incident) {
return null;
}
return (
2026-02-01 00:49:35 +00:00
<Stack
2026-02-28 21:27:33 +00:00
gap={theme.spacing(LAYOUT.MD)}
2026-02-01 00:49:35 +00:00
sx={sx}
>
<SectionHeading>{t("pages.incidents.dialog.details.title")}</SectionHeading>
2026-02-28 21:27:33 +00:00
<BaseBox padding={LAYOUT.MD}>
<Stack gap={theme.spacing(LAYOUT.MD)}>
<SectionHeading>{t("pages.incidents.dialog.details.overview")}</SectionHeading>
2026-02-01 00:49:35 +00:00
<Grid
container
2026-02-28 21:27:33 +00:00
spacing={theme.spacing(LAYOUT.MD)}
2026-02-01 01:54:18 +00:00
alignItems="center"
>
<Grid size={2}>
<Cell>{t("pages.incidents.dialog.details.status")}</Cell>
</Grid>
2026-02-01 01:54:18 +00:00
<Grid size={10}>
<ValueLabel
value={incident.status ? "negative" : "positive"}
text={
incident.status
? t("common.labels.active")
: t("common.labels.resolved")
}
/>
</Grid>
{monitor && (
<>
<Grid size={2}>
<Cell>{t("pages.incidents.dialog.details.monitor")}</Cell>
</Grid>
2026-02-01 01:54:18 +00:00
<Grid size={10}>
<Cell>{monitor.name ?? "N/A"}</Cell>
2026-02-01 01:54:18 +00:00
</Grid>
<Grid size={2}>
<Cell>{t("pages.incidents.dialog.details.url")}</Cell>
2026-02-01 01:54:18 +00:00
</Grid>
<Grid size={10}>
<Cell>{monitor.url ?? "N/A"}</Cell>
2026-02-01 01:54:18 +00:00
</Grid>
</>
)}
</Grid>
</Stack>
</BaseBox>
2026-02-28 21:27:33 +00:00
<BaseBox padding={LAYOUT.MD}>
<Stack gap={theme.spacing(LAYOUT.MD)}>
<SectionHeading>{t("pages.incidents.dialog.details.analysis")}</SectionHeading>
2026-02-01 01:54:18 +00:00
<Grid
container
2026-02-28 21:27:33 +00:00
spacing={theme.spacing(LAYOUT.MD)}
2026-02-01 00:49:35 +00:00
>
2026-02-01 01:54:18 +00:00
<Grid size={6}>
<Cell>{t("pages.incidents.dialog.details.timeline")}</Cell>
2026-02-01 01:54:18 +00:00
</Grid>
<Grid size={6}>
<Cell>{t("pages.incidents.dialog.details.detailsLabel")}</Cell>
2026-02-01 01:54:18 +00:00
</Grid>
<Grid size={6}>
<Divider />
2026-02-01 01:54:18 +00:00
</Grid>
<Grid size={6}>
<Divider />
2026-02-01 01:54:18 +00:00
</Grid>
<Grid size={2}>
<Cell>{t("pages.incidents.dialog.details.startedAt")}</Cell>
2026-02-01 01:54:18 +00:00
</Grid>
<Grid size={4}>
<Cell>
2026-02-01 01:54:18 +00:00
{formatDateWithTz(incident.startTime, "D MMM YYYY, h:mm A", uiTimezone)}
</Cell>
2026-02-01 01:54:18 +00:00
</Grid>
<Grid size={2}>
<Cell>{t("pages.incidents.dialog.details.statusCode")}</Cell>
2026-02-01 01:54:18 +00:00
</Grid>
<Grid size={4}>
<Cell>{incident.statusCode ?? "N/A"}</Cell>
2026-02-01 01:54:18 +00:00
</Grid>
<Grid size={2}>
<Cell>{t("pages.incidents.dialog.details.downtime")}</Cell>
2026-02-01 01:54:18 +00:00
</Grid>
<Grid size={4}>
<Cell>{getIncidentsDuration(incident)}</Cell>
2026-02-01 01:54:18 +00:00
</Grid>
<Grid size={2}>
<Cell>{t("pages.incidents.dialog.details.message")}</Cell>
2026-02-01 01:54:18 +00:00
</Grid>
<Grid size={4}>
<Cell>{incident.message ?? "N/A"}</Cell>
2026-02-01 00:49:35 +00:00
</Grid>
2026-02-01 00:34:48 +00:00
</Grid>
2026-02-01 00:49:35 +00:00
</Stack>
2026-02-01 00:34:48 +00:00
</BaseBox>
2026-02-02 05:41:32 +00:00
{!incident.status && (
2026-02-28 21:27:33 +00:00
<BaseBox padding={LAYOUT.MD}>
<Stack gap={theme.spacing(LAYOUT.XS)}>
<SectionHeading>
2026-02-02 05:41:32 +00:00
{t("pages.incidents.dialog.details.resolutionDetails")}
</SectionHeading>
2026-02-02 05:41:32 +00:00
<Grid
container
2026-02-28 21:27:33 +00:00
spacing={theme.spacing(LAYOUT.MD)}
2026-02-02 05:41:32 +00:00
alignItems="center"
>
<Grid size={2}>
<Cell>{t("pages.incidents.dialog.details.resolvedAt")}</Cell>
2026-02-02 05:41:32 +00:00
</Grid>
<Grid size={10}>
<Cell>
2026-02-02 05:41:32 +00:00
{incident.endTime
? formatDateWithTz(incident.endTime, "D MMM YYYY, h:mm A", uiTimezone)
: "N/A"}
</Cell>
2026-02-02 05:41:32 +00:00
</Grid>
<Grid size={2}>
<Cell>{t("pages.incidents.dialog.details.resolutionType")}</Cell>
2026-02-02 05:41:32 +00:00
</Grid>
<Grid size={10}>
<Cell>
2026-02-02 05:41:32 +00:00
{incident.resolutionType
? t(
`pages.incidents.dialog.details.resolutionTypes.${incident.resolutionType}`
)
: "N/A"}
</Cell>
2026-02-02 05:41:32 +00:00
</Grid>
{incident.resolvedBy && (
<>
<Grid size={2}>
<Cell>{t("pages.incidents.dialog.details.resolvedBy")}</Cell>
2026-02-02 05:41:32 +00:00
</Grid>
<Grid size={10}>
<Cell>{incident.resolvedByEmail ?? incident.resolvedBy}</Cell>
2026-02-02 05:41:32 +00:00
</Grid>
</>
)}
{incident.comment && (
<>
<Grid size={2}>
<Cell>{t("pages.incidents.dialog.details.comment")}</Cell>
2026-02-02 05:41:32 +00:00
</Grid>
<Grid size={10}>
<Cell>{incident.comment}</Cell>
2026-02-02 05:41:32 +00:00
</Grid>
</>
)}
</Grid>
</Stack>
</BaseBox>
)}
2026-02-01 00:34:48 +00:00
</Stack>
);
};