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

83 lines
1.9 KiB
React
Raw Normal View History

2025-01-27 13:18:05 -08:00
// Components
import { Stack, Typography } from "@mui/material";
import StatBox from "../../../../../Components/StatBox";
2025-01-27 14:55:55 -08:00
import SkeletonLayout from "./skeleton";
2025-01-27 13:18:05 -08:00
// Utils
import { useTheme } from "@mui/material/styles";
import useUtils from "../../../Home/Hooks/useUtils";
import { getHumanReadableDuration } from "../../../../../Utils/timeUtils";
2025-01-27 14:58:37 -08:00
import PropTypes from "prop-types";
2025-01-27 14:55:55 -08:00
const StatusBoxes = ({ shouldRender, monitor, certificateExpiry }) => {
2025-01-27 14:58:37 -08:00
// Utils
const theme = useTheme();
const { determineState } = useUtils();
2025-01-27 14:55:55 -08:00
if (!shouldRender) {
return <SkeletonLayout />;
}
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 (
<Stack
direction="row"
gap={theme.spacing(8)}
>
<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>
}
/>
</Stack>
);
};
2025-01-27 14:58:37 -08:00
StatusBoxes.propTypes = {
shouldRender: PropTypes.bool,
monitor: PropTypes.object,
certificateExpiry: PropTypes.string,
};
2025-01-27 13:18:05 -08:00
export default StatusBoxes;