Files
Checkmate/client/src/Components/MonitorStatusHeader/index.jsx
T

58 lines
1.5 KiB
React
Raw Normal View History

2025-01-28 15:42:46 -08:00
import { Stack, Typography } from "@mui/material";
import PulseDot from "../Animated/PulseDot";
import Dot from "../Dot";
import { useTheme } from "@emotion/react";
import useUtils from "../../Pages/Uptime/Monitors/Hooks/useUtils";
import { formatDurationRounded } from "../../Utils/timeUtils";
import ConfigButton from "./ConfigButton";
import SkeletonLayout from "./skeleton";
import PropTypes from "prop-types";
2025-03-19 12:15:04 -07:00
const MonitorStatusHeader = ({ path, isLoading = false, isAdmin, monitor }) => {
2025-01-28 15:42:46 -08:00
const theme = useTheme();
2025-03-19 12:15:04 -07:00
const { statusColor, determineState } = useUtils();
if (isLoading) {
2025-01-28 15:42:46 -08:00
return <SkeletonLayout />;
}
return (
<Stack
direction="row"
justifyContent="space-between"
>
<Stack>
<Typography variant="h1">{monitor?.name}</Typography>
2025-01-28 15:42:46 -08:00
<Stack
direction="row"
alignItems={"center"}
2025-04-27 12:05:16 +05:30
gap={theme.spacing(4)}
2025-01-28 15:42:46 -08:00
>
<PulseDot color={statusColor[determineState(monitor)]} />
2025-04-27 12:05:16 +05:30
<Typography variant="h2"
style={{fontFamily : "monospace" , fontWeight : 'bolder'}}
>
2025-01-28 15:42:46 -08:00
{monitor?.url?.replace(/^https?:\/\//, "") || "..."}
</Typography>
<Dot />
<Typography>
Checking every {formatDurationRounded(monitor?.interval)}.
</Typography>
</Stack>
</Stack>
<ConfigButton
2025-01-31 10:06:57 -08:00
path={path}
2025-01-28 15:42:46 -08:00
shouldRender={isAdmin}
monitorId={monitor?._id}
2025-01-28 15:42:46 -08:00
/>
</Stack>
);
};
MonitorStatusHeader.propTypes = {
2025-01-31 10:06:57 -08:00
path: PropTypes.string.isRequired,
2025-03-19 12:15:04 -07:00
isLoading: PropTypes.bool,
2025-01-28 15:42:46 -08:00
isAdmin: PropTypes.bool,
monitor: PropTypes.object,
};
export default MonitorStatusHeader;