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

39 lines
813 B
React
Raw Normal View History

2025-01-28 11:04:11 -08:00
import { Stack, Button } from "@mui/material";
import { useNavigate } from "react-router-dom";
import PropTypes from "prop-types";
import SkeletonLayout from "./skeleton";
2025-02-07 14:47:52 -08:00
const CreateMonitorHeader = ({
isAdmin,
label = "Create new",
shouldRender = true,
path,
}) => {
2025-01-28 11:04:11 -08:00
const navigate = useNavigate();
if (!isAdmin) return null;
if (!shouldRender) return <SkeletonLayout />;
return (
<Stack
direction="row"
justifyContent="end"
alignItems="center"
>
<Button
variant="contained"
color="accent"
onClick={() => navigate(path)}
>
2025-02-07 14:47:52 -08:00
{label}
2025-01-28 11:04:11 -08:00
</Button>
</Stack>
);
};
export default CreateMonitorHeader;
CreateMonitorHeader.propTypes = {
isAdmin: PropTypes.bool.isRequired,
2025-01-31 07:09:22 -08:00
shouldRender: PropTypes.bool,
2025-01-28 11:04:11 -08:00
path: PropTypes.string.isRequired,
2025-02-07 14:47:52 -08:00
label: PropTypes.string,
2025-01-28 11:04:11 -08:00
};