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

@@ -1,21 +1,14 @@
import {
Table,
Pagination,
ValueLabel,
StatusLabel,
Tooltip,
StatusCodeLabel,
} from "@/Components/design-elements";
import Box from "@mui/material/Box";
import type { Header } from "@/Components/design-elements/Table";
import type { Monitor } from "@/Types/Monitor";
import { useTranslation } from "react-i18next";
import { formatDateWithTz } from "@/Utils/TimeUtils";
import {
formatStatusCode,
getStatusCodeTooltip,
getStatusCodeValueType,
} from "@/Utils/statusCode";
import type { Check } from "@/Types/Check";
import type { RootState } from "@/Types/state";
import { useSelector } from "react-redux";
@@ -40,7 +33,7 @@ export const ChecksTable = ({
const { t } = useTranslation();
const uiTimezone = useSelector((state: RootState) => state.ui.timezone);
const getHeaders = (t: (key: string) => string, uiTimezone: string) => {
const getHeaders = () => {
const headers: Header<Check>[] = [
{
id: "monitorName",
@@ -74,23 +67,12 @@ export const ChecksTable = ({
id: "statusCode",
content: t("pages.checks.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
);
},
},
{
@@ -104,7 +86,7 @@ export const ChecksTable = ({
return headers;
};
const headers = getHeaders(t, uiTimezone);
const headers = getHeaders();
const handlePageChange = (
_e: React.MouseEvent<HTMLButtonElement> | null,