diff --git a/Client/src/Pages/PageSpeed/card.jsx b/Client/src/Pages/PageSpeed/card.jsx index 6b87703f5..e45cc3b45 100644 --- a/Client/src/Pages/PageSpeed/card.jsx +++ b/Client/src/Pages/PageSpeed/card.jsx @@ -1,13 +1,92 @@ import PropTypes from "prop-types"; import PageSpeedIcon from "../../assets/icons/page-speed.svg?react"; import { StatusLabel } from "../../Components/Label"; -import { Box, Grid, Typography } from "@mui/material"; +import { Box, Grid, Stack, Typography } from "@mui/material"; import { useNavigate } from "react-router"; import { useTheme } from "@emotion/react"; import { IconBox } from "./Details/styled"; -import { Area, AreaChart, CartesianGrid, ResponsiveContainer } from "recharts"; +import { + Area, + AreaChart, + CartesianGrid, + ResponsiveContainer, + Tooltip, +} from "recharts"; +import { useSelector } from "react-redux"; +import { formatDateWithTz } from "../../Utils/timeUtils"; import useUtils from "../Monitors/utils"; +/** + * CustomToolTip displays a tooltip with formatted date and score information. + * @param {Object} props + * @param {Array} props.payload - Data to display in the tooltip + * @returns {JSX.Element} The rendered tooltip component + */ +const CustomToolTip = ({ payload }) => { + const theme = useTheme(); + const uiTimezone = useSelector((state) => state.ui.timezone); + + return ( + + + {formatDateWithTz( + payload[0]?.payload.createdAt, + "ddd, MMMM D, YYYY, h:mm A", + uiTimezone + )} + + + + + + {payload[0]?.name} + {" "} + {payload[0]?.payload.score} + + + ); +}; + +CustomToolTip.propTypes = { + payload: PropTypes.array, +}; + /** * Processes the raw data to include a score for each entry. * @param {Array} data - The raw data array. @@ -64,10 +143,10 @@ const PagespeedAreaChart = ({ data, status }) => { fill="transparent" vertical={false} /> - {/* } - /> */} + content={} + /> { strokeWidth={1.5} fill={`url(#pagespeed-chart-${status})`} activeDot={{ - stroke: pagespeedStyles[status].stroke, + stroke: pagespeedStyles[status].light, fill: pagespeedStyles[status].stroke, r: 4.5, }} @@ -118,7 +197,7 @@ PagespeedAreaChart.propTypes = { /** * Renders a card displaying monitor details and an area chart. - * @param {Object} props + * @param {Object} props * @param {Object} props.monitor - The monitor data to be displayed in the card. * @returns {JSX.Element} - The rendered card. */