Files
Checkmate/client/src/Pages/Uptime/Details/Components/ResponseTable/index.jsx
T

91 lines
2.1 KiB
React
Raw Normal View History

import ChartBox from "../../../../../Components/Charts/ChartBox";
2025-01-27 14:55:55 -08:00
import PropTypes from "prop-types";
import HistoryIcon from "../../../../../assets/icons/history-icon.svg?react";
import Table from "../../../../../Components/Table";
import TablePagination from "../../../../../Components/Table/TablePagination";
import { StatusLabel } from "../../../../../Components/Label";
2025-03-17 01:16:42 +05:30
import { useTranslation } from "react-i18next";
2025-01-27 14:55:55 -08:00
import { formatDateWithTz } from "../../../../../Utils/timeUtils";
import SkeletonLayout from "./skeleton";
const ResponseTable = ({
2025-03-19 12:15:04 -07:00
isLoading = false,
2025-01-29 11:42:02 -08:00
checks = [],
2025-01-27 14:55:55 -08:00
checksCount,
uiTimezone,
page,
setPage,
rowsPerPage,
setRowsPerPage,
}) => {
2025-03-17 01:16:42 +05:30
const { t } = useTranslation();
2025-03-19 12:15:04 -07:00
if (isLoading) {
2025-01-27 14:55:55 -08:00
return <SkeletonLayout />;
}
const headers = [
{
id: "status",
2025-03-17 01:16:42 +05:30
content: t("status"),
2025-01-27 14:55:55 -08:00
render: (row) => {
const status = row.status === true ? "up" : "down";
return (
<StatusLabel
status={status}
text={status}
customStyles={{ textTransform: "capitalize" }}
/>
);
},
},
{
id: "date",
2025-03-17 01:16:42 +05:30
content: t("date&Time"),
2025-01-27 14:55:55 -08:00
render: (row) =>
formatDateWithTz(row.createdAt, "ddd, MMMM D, YYYY, HH:mm A", uiTimezone),
},
{
id: "statusCode",
2025-03-17 01:16:42 +05:30
content: t("statusCode"),
2025-01-27 14:55:55 -08:00
render: (row) => (row.statusCode ? row.statusCode : "N/A"),
},
{
id: "message",
2025-03-17 01:16:42 +05:30
content: t("message"),
2025-01-27 14:55:55 -08:00
render: (row) => row.message,
},
];
return (
<ChartBox
icon={<HistoryIcon />}
header="Response Times"
height="100%"
>
<Table
headers={headers}
data={checks}
/>
<TablePagination
page={page}
handleChangePage={setPage}
rowsPerPage={rowsPerPage}
handleChangeRowsPerPage={setRowsPerPage}
itemCount={checksCount}
/>
</ChartBox>
);
};
ResponseTable.propTypes = {
2025-03-19 12:15:04 -07:00
isLoading: PropTypes.bool,
2025-01-29 11:42:02 -08:00
checks: PropTypes.array,
checksCount: PropTypes.number,
2025-01-27 14:55:55 -08:00
uiTimezone: PropTypes.string.isRequired,
page: PropTypes.number.isRequired,
setPage: PropTypes.func.isRequired,
rowsPerPage: PropTypes.number.isRequired,
setRowsPerPage: PropTypes.func.isRequired,
};
export default ResponseTable;