Files
Checkmate/Client/src/Pages/Uptime/Details/Components/UptimeStatusBoxes/index.jsx
T

66 lines
1.7 KiB
React
Raw Normal View History

import StatusBoxes from "../../../../../Components/StatusBoxes";
2025-01-27 13:18:05 -08:00
import StatBox from "../../../../../Components/StatBox";
import { getHumanReadableDuration } from "../../../../../Utils/timeUtils";
2025-01-27 13:18:05 -08:00
import { useTheme } from "@mui/material/styles";
import { Typography } from "@mui/material";
2025-01-28 11:05:06 -08:00
import useUtils from "../../../Monitors/Hooks/useUtils";
const UptimeStatusBoxes = ({ shouldRender, monitor, certificateExpiry }) => {
2025-01-27 14:58:37 -08:00
const theme = useTheme();
const { determineState } = useUtils();
2025-01-27 13:18:05 -08:00
const { time: streakTime, units: streakUnits } = getHumanReadableDuration(
monitor?.uptimeStreak
);
const { time: lastCheckTime, units: lastCheckUnits } = getHumanReadableDuration(
monitor?.timeSinceLastCheck
);
return (
<StatusBoxes shouldRender={shouldRender}>
2025-01-27 13:18:05 -08:00
<StatBox
gradient={true}
status={determineState(monitor)}
heading={"active for"}
subHeading={
<>
{streakTime}
<Typography component="span">{streakUnits}</Typography>
</>
}
/>
<StatBox
heading="last check"
subHeading={
<>
{lastCheckTime}
<Typography component="span">{lastCheckUnits}</Typography>
<Typography component="span">{"ago"}</Typography>
</>
}
/>
<StatBox
heading="last response time"
subHeading={
<>
{monitor?.latestResponseTime}
<Typography component="span">{"ms"}</Typography>
</>
}
/>
<StatBox
heading="certificate expiry"
subHeading={
<Typography
component="span"
fontSize={13}
color={theme.palette.primary.contrastText}
>
{certificateExpiry}
</Typography>
}
/>
</StatusBoxes>
2025-01-27 13:18:05 -08:00
);
};
export default UptimeStatusBoxes;