Files
Checkmate/client/src/Pages/Incidents/Components/StatusBoxes/StatusBox.jsx
T

116 lines
2.8 KiB
React
Raw Normal View History

2025-07-01 15:54:50 +05:30
import PropTypes from "prop-types";
import { useTheme } from "@emotion/react";
import { Box, Stack, Typography } from "@mui/material";
import Background from "../../../../assets/Images/background-grid.svg?react";
import AlertIcon from "../../../../assets/icons/alert-icon.svg?react";
import CheckIcon from "../../../../assets/icons/check-icon.svg?react";
import CloseIcon from "../../../../assets/icons/close-icon.svg?react";
import WarningIcon from "../../../../assets/icons/warning-icon.svg?react";
2025-08-01 21:11:46 +05:30
import "./StatusBox.css";
2025-08-01 21:15:12 +05:30
2025-07-01 15:54:50 +05:30
const StatusBox = ({ title, value, status }) => {
const theme = useTheme();
let sharedStyles = {
position: "absolute",
right: 8,
"& svg path": { stroke: theme.palette.primary.contrastTextTertiary },
};
let color;
let icon;
if (status === "up") {
color = theme.palette.success.lowContrast;
icon = (
2025-07-02 12:51:27 +05:30
<Box sx={{ ...sharedStyles, top: theme.spacing(6), right: theme.spacing(6) }}>
<CheckIcon />
2025-07-01 15:54:50 +05:30
</Box>
);
} else if (status === "down") {
color = theme.palette.error.lowContrast;
icon = (
2025-07-02 12:51:27 +05:30
<Box sx={{ ...sharedStyles, top: theme.spacing(6), right: theme.spacing(6) }}>
<CloseIcon />
2025-07-01 15:54:50 +05:30
</Box>
);
} else if (status === "paused") {
color = theme.palette.warning.lowContrast;
icon = (
2025-07-02 12:51:27 +05:30
<Box sx={{ ...sharedStyles, top: theme.spacing(6), right: theme.spacing(6) }}>
<WarningIcon />
2025-07-01 15:54:50 +05:30
</Box>
);
} else {
2025-07-01 18:10:35 +05:30
color = theme.palette.accent.main;
icon = (
2025-07-02 12:51:27 +05:30
<Box sx={{ ...sharedStyles, top: theme.spacing(6), right: theme.spacing(6) }}>
<AlertIcon />
2025-07-01 18:10:35 +05:30
</Box>
);
}
2025-07-01 15:54:50 +05:30
return (
<Box
position="relative"
flex={1}
border={1}
backgroundColor={theme.palette.primary.main}
borderColor={theme.palette.primary.lowContrast}
borderRadius={theme.shape.borderRadius}
p={theme.spacing(8)}
overflow="hidden"
>
<Box
position="absolute"
top="-10%"
left="5%"
>
<Background />
</Box>
<Stack direction="column">
<Stack
direction="row"
alignItems="center"
mb={theme.spacing(8)}
>
<Typography
variant={"h2"}
textTransform="uppercase"
color={theme.palette.primary.contrastTextTertiary}
>
{title}
</Typography>
{icon}
</Stack>
<Stack
direction="row"
alignItems="flex-start"
2025-07-02 12:51:27 +05:30
fontSize={theme.typography.h1.fontSize}
2025-07-01 15:54:50 +05:30
fontWeight={600}
color={color}
2025-07-02 12:51:27 +05:30
gap={theme.spacing(1)}
2025-07-01 15:54:50 +05:30
>
{value}
<Typography
2025-07-02 12:51:27 +05:30
fontSize={theme.typography.label.fontSize}
2025-07-01 15:54:50 +05:30
fontWeight={300}
color={theme.palette.primary.contrastTextSecondary}
sx={{
opacity: 0.3,
}}
>
#
</Typography>
</Stack>
</Stack>
</Box>
);
};
StatusBox.propTypes = {
2025-07-01 18:23:11 +05:30
title: PropTypes.string.isRequired,
2025-07-01 15:54:50 +05:30
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
status: PropTypes.string,
};
2025-07-01 18:10:35 +05:30
export default StatusBox;