Files
Checkmate/client/src/Pages/PageSpeed/Details/Components/PageSpeedStatusBoxes/index.jsx
T

49 lines
1.3 KiB
React
Raw Normal View History

2025-09-27 14:54:55 -07:00
import StatusBoxes from "@/Components/v1/StatusBoxes/index.jsx";
import StatBox from "@/Components/v1/StatBox/index.jsx";
2025-01-28 15:42:46 -08:00
import { Typography } from "@mui/material";
2026-01-12 23:57:39 +00:00
import { getHumanReadableDuration } from "../../../../../Utils/timeUtils.js";
2025-03-17 01:16:42 +05:30
import { useTranslation } from "react-i18next";
2025-01-28 15:42:46 -08:00
2026-01-16 21:04:41 +00:00
const PageSpeedStatusBoxes = ({ shouldRender, monitorStats }) => {
const lastChecked = monitorStats?.lastCheckTimestamp
? Date.now() - monitorStats.lastCheckTimestamp
: 0;
// Determine time since last failure
const timeOfLastFailure = monitorStats?.timeOfLastFailure;
const timeSinceLastFailure =
timeOfLastFailure > 0
? Date.now() - timeOfLastFailure
: Date.now() - new Date(monitorStats?.createdAt);
const streakTime = getHumanReadableDuration(timeSinceLastFailure);
const time = getHumanReadableDuration(lastChecked);
2025-01-28 15:42:46 -08:00
2025-03-17 01:16:42 +05:30
const { t } = useTranslation();
2025-01-28 15:42:46 -08:00
return (
<StatusBoxes shouldRender={shouldRender}>
<StatBox
heading="checks since"
subHeading={
<>
2026-01-16 21:04:41 +00:00
{streakTime}
2025-03-17 01:16:42 +05:30
<Typography component="span">{t("ago")}</Typography>
2025-01-28 15:42:46 -08:00
</>
}
/>
<StatBox
heading="last check"
subHeading={
<>
2025-06-17 13:41:25 +08:00
{time}
2025-03-17 01:16:42 +05:30
<Typography component="span">{t("ago")}</Typography>
2025-01-28 15:42:46 -08:00
</>
}
/>
</StatusBoxes>
);
};
export default PageSpeedStatusBoxes;