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

129 lines
3.8 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";
import { BaseBox, ValueLabel } from "@/Components/v2/design-elements";
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
}
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
gap={theme.spacing(4)}
sx={sx}
>
2026-02-01 00:34:48 +00:00
<Typography textTransform={"uppercase"}>
{t("pages.incidents.dialog.details.title")}
</Typography>
<BaseBox padding={8}>
2026-02-01 00:49:35 +00:00
<Stack gap={theme.spacing(4)}>
<Typography textTransform={"uppercase"}>
{t("pages.incidents.dialog.details.overview")}
</Typography>
<Divider />
2026-02-01 00:34:48 +00:00
2026-02-01 00:49:35 +00:00
<Grid
container
2026-02-01 01:54:18 +00:00
spacing={theme.spacing(4)}
alignItems="center"
>
<Grid size={2}>{t("pages.incidents.dialog.details.status")}</Grid>
<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}>{t("pages.incidents.dialog.details.monitor")}</Grid>
<Grid size={10}>
<Typography>{monitor.name ?? "N/A"}</Typography>
</Grid>
<Grid size={2}>
<Typography>{t("pages.incidents.dialog.details.url")}</Typography>
</Grid>
<Grid size={10}>
<Typography>{monitor.url ?? "N/A"}</Typography>
</Grid>
</>
)}
</Grid>
</Stack>
</BaseBox>
<BaseBox padding={8}>
<Stack gap={theme.spacing(4)}>
<Typography textTransform={"uppercase"}>{t("pages.incidents.dialog.details.analysis")}</Typography>
<Divider />
<Grid
container
spacing={theme.spacing(2)}
2026-02-01 00:49:35 +00:00
>
2026-02-01 01:54:18 +00:00
<Grid size={6}>
<Typography>{t("pages.incidents.dialog.details.timeline")}</Typography>
</Grid>
<Grid size={6}>
<Typography>{t("pages.incidents.dialog.details.detailsLabel")}</Typography>
</Grid>
<Grid size={6}>
<Divider></Divider>
</Grid>
<Grid size={6}>
<Divider></Divider>
</Grid>
<Grid size={2}>
<Typography>{t("pages.incidents.dialog.details.startedAt")}</Typography>
</Grid>
<Grid size={4}>
<Typography>
{formatDateWithTz(incident.startTime, "D MMM YYYY, h:mm A", uiTimezone)}
</Typography>
</Grid>
<Grid size={2}>
<Typography>{t("pages.incidents.dialog.details.statusCode")}</Typography>
</Grid>
<Grid size={4}>
<Typography>{incident.statusCode ?? "N/A"}</Typography>
</Grid>
<Grid size={2}>
<Typography>{t("pages.incidents.dialog.details.downtime")}</Typography>
</Grid>
<Grid size={4}>
<Typography>{getIncidentsDuration(incident)}</Typography>
</Grid>
<Grid size={2}>
<Typography>{t("pages.incidents.dialog.details.message")}</Typography>
</Grid>
<Grid size={4}>
<Typography>{incident.message ?? "N/A"}</Typography>
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>
</Stack>
);
};