import ChartBox from "@/Components/v1/Charts/ChartBox/index.jsx"; import PropTypes from "prop-types"; import HistoryIcon from "../../../../../../assets/icons/history-icon.svg?react"; import Table from "@/Components/v1/Table/index.jsx"; import TablePagination from "@/Components/v1/Table/TablePagination/index.jsx"; import { StatusLabel } from "@/Components/v1/Label/index.jsx"; import { useTranslation } from "react-i18next"; import { formatDateWithTz } from "../../../../../../Utils/timeUtils.js"; import SkeletonLayout from "./skeleton.jsx"; import Tooltip from "@mui/material/Tooltip"; import Box from "@mui/material/Box"; import Typography from "@mui/material/Typography"; import Stack from "@mui/material/Stack"; import { lighten, useTheme } from "@mui/material"; /** * Creates tooltip content with detailed timing breakdown * Following the pattern from IncidentTable's GetTooltip function * @param {Object} timings - Timing object (guaranteed to have phases by caller) * @param {Object} theme - MUI theme object * @param {Function} t - Translation function * @returns {JSX.Element} Tooltip content */ const GetTooltip = (timings, theme, t) => { const phases = timings.phases; const timingDetails = [ { label: t("dnsLookup"), value: phases.dns }, { label: t("tcpConnection"), value: phases.tcp }, { label: t("tlsHandshake"), value: phases.tls }, { label: t("waitTime"), value: phases.wait }, { label: t("timeToFirstByte"), value: phases.firstByte }, { label: t("download"), value: phases.download }, { label: t("total"), value: phases.total }, ].filter((item) => item.value > 0); return ( {t("responseTimeBreakdown")} {timingDetails.map((detail, index, array) => ( {detail.label}: {Math.round(detail.value)} ms ))} ); }; const ResponseTable = ({ isLoading = false, checks = [], checksCount, uiTimezone, page, setPage, rowsPerPage, setRowsPerPage, }) => { const { t } = useTranslation(); const theme = useTheme(); if (isLoading) { return ; } const headers = [ { id: "status", content: t("status"), render: (row) => { const status = row.status === true ? "up" : "down"; return ( ); }, }, { id: "date", content: t("date&Time"), render: (row) => formatDateWithTz(row.createdAt, "ddd, MMMM D, YYYY, HH:mm A", uiTimezone), }, { id: "statusCode", content: t("statusCode"), render: (row) => (row.statusCode ? row.statusCode : "N/A"), }, { id: "message", content: t("message"), render: (row) => row.message, }, { id: "responseTime", content: t("responseTime"), render: (row) => { const hasTimings = row.timings && row.timings.phases; const responseTime = row.responseTime; const responseTimeDisplay = responseTime !== null && responseTime !== undefined ? `${Math.round(responseTime)} ms` : "N/A"; if (!hasTimings) { return responseTimeDisplay; } return ( {responseTimeDisplay} ); }, }, ]; return ( } header="Response Times" height="100%" > ); }; ResponseTable.propTypes = { isLoading: PropTypes.bool, checks: PropTypes.array, checksCount: PropTypes.number, uiTimezone: PropTypes.string.isRequired, page: PropTypes.number.isRequired, setPage: PropTypes.func.isRequired, rowsPerPage: PropTypes.number.isRequired, setRowsPerPage: PropTypes.func.isRequired, }; export default ResponseTable;