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-01-28 11:04:11 -08:00
|
|
|
|
2025-02-07 14:47:52 -08:00
|
|
|
const CreateMonitorHeader = ({
|
|
|
|
|
isAdmin,
|
2025-05-09 14:58:13 -04:00
|
|
|
label,
|
2025-05-06 00:41:40 +05:30
|
|
|
isLoading = true,
|
2025-02-07 14:47:52 -08:00
|
|
|
path,
|
2025-04-27 03:05:14 +05:30
|
|
|
bulkPath,
|
2025-02-07 14:47:52 -08:00
|
|
|
}) => {
|
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-09 14:58:13 -04: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)}
|
|
|
|
|
>
|
2025-05-09 14:58:13 -04:00
|
|
|
{label || t("createNew")}
|
2025-01-28 11:04:11 -08:00
|
|
|
</Button>
|
2025-04-27 03:05:14 +05:30
|
|
|
{bulkPath && (
|
|
|
|
|
<Button
|
2025-05-06 00:41:40 +05:30
|
|
|
loading={isLoading}
|
2025-04-27 03:05:14 +05:30
|
|
|
variant="contained"
|
|
|
|
|
color="accent"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
navigate(`${bulkPath}`);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{t("bulkImport.title")}
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
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
|
|
|
};
|