refactor all call sites

This commit is contained in:
Alex committed 2026-05-07 09:54:58 -07:00
1 parent 0827d4f528
commit 1d90b8d8d9
5 files changed
+78 -137

No files matched your search

@@ -2,7 +2,7 @@ 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, Tooltip } from "@/Components/design-elements";
import { BaseBox, ValueLabel, StatusCodeLabel } from "@/Components/design-elements";
import { LAYOUT } from "@/Utils/Theme/constants";
import { useTranslation } from "react-i18next";
@@ -13,7 +13,6 @@ import { useSelector } from "react-redux";
import type { RootState } from "@/Types/state";
import { formatDateWithTz } from "@/Utils/TimeUtils";
import { getIncidentsDuration } from "@/Pages/Incidents/utils";
import { formatStatusCode, getStatusCodeTooltip } from "@/Utils/statusCode";
interface CardDetailsProps {
incident: Incident | null;
@@ -48,13 +47,6 @@ export const CardDetails = ({ incident, monitor, sx }: CardDetailsProps) => {
return null;
}
const statusCodeText = formatStatusCode(incident.statusCode, t);
const statusCodeTooltip = getStatusCodeTooltip(
incident.statusCode,
incident.message,
t
);
return (
<Stack
gap={theme.spacing(LAYOUT.MD)}
@@ -133,13 +125,10 @@ export const CardDetails = ({ incident, monitor, sx }: CardDetailsProps) => {
</Grid>
<Grid size={4}>
<Cell>
{statusCodeTooltip ? (
<Tooltip title={statusCodeTooltip}>
<span>{statusCodeText}</span>
</Tooltip>
) : (
statusCodeText
)}
<StatusCodeLabel
statusCode={incident.statusCode}
message={incident.message}
/>
</Cell>
</Grid>
<Grid size={2}>
@@ -1,4 +1,4 @@
import { Table, ValueLabel, Tooltip } from "@/Components/design-elements";
import { Table, ValueLabel, StatusCodeLabel } from "@/Components/design-elements";
import { Pagination } from "@/Components/design-elements/Table";
import type { Header } from "@/Components/design-elements/Table";
import { ActionsMenu } from "@/Components/actions-menu";
@@ -14,11 +14,6 @@ import Typography from "@mui/material/Typography";
import { useTheme } from "@mui/material/styles";
import Box from "@mui/material/Box";
import { getMonitorPath } from "@/Utils/MonitorUtils";
import {
formatStatusCode,
getStatusCodeTooltip,
getStatusCodeValueType,
} from "@/Utils/statusCode";
interface IncidentsTableProps {
title?: string;
@@ -139,13 +134,12 @@ export const IncidentsTable = ({
return (
<Typography
variant="body2"
sx={{
textTransform: "capitalize",
color:
row.resolutionType === "manual"
? theme.palette.warning.main
: theme.palette.success.main,
}}
color={
row.resolutionType === "manual"
? theme.palette.warning.main
: theme.palette.success.main
}
textTransform={"capitalize"}
>
{row.resolutionType}
</Typography>
@@ -158,23 +152,12 @@ export const IncidentsTable = ({
id: "statusCode",
content: t("pages.incidents.table.headers.statusCode"),
render: (row) => {
const code = row.statusCode;
if (!code) return "N/A";
const text = formatStatusCode(code, t);
const tooltip = getStatusCodeTooltip(code, row.message, t);
const label = (
<ValueLabel
value={getStatusCodeValueType(code)}
text={text}
return (
<StatusCodeLabel
statusCode={row.statusCode}
message={row.message}
/>
);
return tooltip ? (
<Tooltip title={tooltip}>
<span>{label}</span>
</Tooltip>
) : (
label
);
},
},
{