diff --git a/Client/src/Components/Charts/StatusPageBarChart/index.jsx b/Client/src/Components/Charts/StatusPageBarChart/index.jsx new file mode 100644 index 000000000..5acf4c3d6 --- /dev/null +++ b/Client/src/Components/Charts/StatusPageBarChart/index.jsx @@ -0,0 +1,175 @@ +import { useTheme } from "@emotion/react"; +import { Box, Stack, Tooltip, Typography } from "@mui/material"; +import { formatDateWithTz } from "../../../Utils/timeUtils"; +import { useEffect, useState } from "react"; +import { useSelector } from "react-redux"; + +/* TODO add prop validation and jsdocs */ +const StatusPageBarChart = ({ checks = [] }) => { + const theme = useTheme(); + const [animate, setAnimate] = useState(false); + const uiTimezone = useSelector((state) => state.ui.timezone); + + useEffect(() => { + setAnimate(true); + }, []); + + // set responseTime to average if there's only one check + if (checks.length === 1) { + checks[0] = { ...checks[0], responseTime: 50 }; + } + + if (checks.length !== 25) { + const placeholders = Array(25 - checks.length).fill("placeholder"); + checks = [...checks, ...placeholders]; + } + + return ( + event.stopPropagation()} + sx={{ + cursor: "default", + }} + > + {checks.map((check, index) => + check === "placeholder" ? ( + /* TODO what is the purpose of this box? */ + // CAIO_REVIEW the purpose of this box is to make sure there are always at least 25 bars + // even if there are less than 25 checks + + ) : ( + + + {formatDateWithTz( + check.createdAt, + "ddd, MMMM D, YYYY, HH:mm A", + uiTimezone + )} + + + + + + Response Time + + + {check.originalResponseTime} + + {" "} + ms + + + + + + } + placement="top" + key={`check-${check?._id}`} + slotProps={{ + popper: { + className: "bar-tooltip", + modifiers: [ + { + name: "offset", + options: { + offset: [0, -10], + }, + }, + ], + sx: { + "& .MuiTooltip-tooltip": { + backgroundColor: theme.palette.secondary.main, + border: 1, + borderColor: theme.palette.primary.lowContrast, + borderRadius: theme.shape.borderRadius, + boxShadow: theme.shape.boxShadow, + px: theme.spacing(4), + py: theme.spacing(3), + }, + "& .MuiTooltip-tooltip p": { + /* TODO Font size should point to theme */ + fontSize: 12, + color: theme.palette.secondary.contrastText, + fontWeight: 500, + }, + "& .MuiTooltip-tooltip span": { + /* TODO Font size should point to theme */ + fontSize: 11, + color: theme.palette.secondary.contrastText, + fontWeight: 600, + }, + }, + }, + }} + > + + + + + ) + )} + + ); +}; + +export default StatusPageBarChart; diff --git a/Client/src/Components/Image/index.jsx b/Client/src/Components/Image/index.jsx new file mode 100644 index 000000000..98d8b7707 --- /dev/null +++ b/Client/src/Components/Image/index.jsx @@ -0,0 +1,32 @@ +import { Box } from "@mui/material"; +import PropTypes from "prop-types"; + +const Image = ({ + src, + alt, + width = "auto", + height = "auto", + maxWidth = "auto", + maxHeight = "auto", +}) => { + return ( + + ); +}; + +Image.propTypes = { + src: PropTypes.string, + alt: PropTypes.string.isRequired, + width: PropTypes.string, + height: PropTypes.string, +}; + +export default Image; diff --git a/Client/src/Pages/StatusPage/Create/Components/Tabs/Content.jsx b/Client/src/Pages/StatusPage/Create/Components/Tabs/Content.jsx index 6dd08acb0..8eda4fe0a 100644 --- a/Client/src/Pages/StatusPage/Create/Components/Tabs/Content.jsx +++ b/Client/src/Pages/StatusPage/Create/Components/Tabs/Content.jsx @@ -47,19 +47,6 @@ const Content = ({ direction="row" justifyContent="space-between" > - {/* - {" "} - Servers list{" "} - - */}