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

45 lines
1.1 KiB
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";
2025-04-27 03:05:14 +05:30
import { useTranslation } from "react-i18next";
import { useTheme } from "@emotion/react";
2025-06-18 01:07:22 +05:30
import MonitorActions from "../MonitorActions";
2025-01-28 11:04:11 -08:00
2025-05-27 09:10:32 -07:00
const CreateMonitorHeader = ({ isAdmin, label, isLoading = true, path, bulkPath }) => {
2025-01-28 11:04:11 -08:00
const navigate = useNavigate();
2025-04-27 03:05:14 +05:30
const { t } = useTranslation();
const theme = useTheme();
2025-05-27 09:10:32 -07:00
// Use the provided label or fall back to the translated default
2025-04-27 03:05:14 +05:30
2025-01-28 11:04:11 -08:00
if (!isAdmin) return null;
2025-04-27 03:05:14 +05:30
2025-01-28 11:04:11 -08:00
return (
<Stack
direction="row"
justifyContent="end"
alignItems="center"
2025-04-27 03:05:14 +05:30
gap={theme.spacing(6)}
2025-01-28 11:04:11 -08:00
>
<Button
2025-05-06 00:41:40 +05:30
loading={isLoading}
2025-01-28 11:04:11 -08:00
variant="contained"
color="accent"
onClick={() => navigate(path)}
>
{label || t("createNew")}
2025-01-28 11:04:11 -08:00
</Button>
2025-06-24 10:52:19 +08:00
{/* {bulkPath && <MonitorActions isLoading={isLoading} />} */}
2025-01-28 11:04:11 -08:00
</Stack>
);
};
export default CreateMonitorHeader;
CreateMonitorHeader.propTypes = {
isAdmin: PropTypes.bool.isRequired,
2025-05-06 00:41:40 +05:30
isLoading: 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-04-27 03:05:14 +05:30
bulkPath: PropTypes.string,
2025-01-28 11:04:11 -08:00
};