diff --git a/client/src/Pages/Checks/Components/IncidentTable/index.jsx b/client/src/Pages/Checks/Components/IncidentTable/index.jsx
deleted file mode 100644
index bac2a00cb..000000000
--- a/client/src/Pages/Checks/Components/IncidentTable/index.jsx
+++ /dev/null
@@ -1,233 +0,0 @@
-//Components
-import Stack from "@mui/material/Stack";
-import DataTable from "@/Components/v1/Table/index.jsx";
-import Table from "@mui/material/Table";
-import TableBody from "@mui/material/TableBody";
-import TableRow from "@mui/material/TableRow";
-import TableCell from "@mui/material/TableCell";
-import TableSkeleton from "@/Components/v1/Table/skeleton.jsx";
-import Pagination from "@/Components/v1/Table/TablePagination/index.jsx";
-import { StatusLabel } from "@/Components/v1/Label/index.jsx";
-import { HttpStatusLabel } from "@/Components/v1/HttpStatusLabel/index.jsx";
-import GenericFallback from "@/Components/v1/GenericFallback/index.jsx";
-import NetworkError from "@/Components/v1/GenericFallback/NetworkError.jsx";
-
-//Utils
-import { formatDateWithTz } from "@/Utils/timeUtilsLegacy.js";
-import { useSelector } from "react-redux";
-import { useState } from "react";
-import PropTypes from "prop-types";
-import { useTranslation } from "react-i18next";
-import { useFetchChecksTeam, useFetchChecksByMonitor } from "@/Hooks/checkHooks.js";
-import { Typography, useTheme } from "@mui/material";
-import { lighten } from "@mui/material/styles";
-
-const GetTooltip = (row) => {
- const theme = useTheme();
- const phases = row?.timings?.phases;
-
- const phaseKeyFormattingMap = {
- firstByte: "first byte",
- };
- return (
-
- {`Status code: ${row?.statusCode}`}
- {`Response time: ${row?.responseTime} ms`}
- {phases && (
- <>
- {`Request timing: `}
-
-
- {Object.keys(phases)?.map((phaseKey) => (
-
-
-
- {`${phaseKeyFormattingMap[phaseKey] || phaseKey}:`}
-
-
-
- {`${phases[phaseKey]} ms`}
-
-
- ))}
-
-
- >
- )}
-
- );
-};
-
-const IncidentTable = ({
- isLoading,
- monitors,
- selectedMonitor,
- filter,
- dateRange,
- updateTrigger,
-}) => {
- //Redux state
- const uiTimezone = useSelector((state) => state.ui.timezone);
-
- //Local state
- const [page, setPage] = useState(0);
- const [rowsPerPage, setRowsPerPage] = useState(10);
- const selectedMonitorDetails = monitors?.[selectedMonitor];
- const selectedMonitorType = selectedMonitorDetails?.type;
-
- //Hooks
- const [checksMonitor, checksCountMonitor, isLoadingMonitor, networkErrorMonitor] =
- useFetchChecksByMonitor({
- monitorId: selectedMonitor === "0" ? undefined : selectedMonitor,
- type: selectedMonitorType,
- status: false,
- sortOrder: "desc",
- limit: null,
- dateRange,
- filter: filter === "resolved" ? "all" : filter,
- ack: filter === "resolved" ? true : false,
- page: page,
- rowsPerPage: rowsPerPage,
- enabled: selectedMonitor !== "0",
- updateTrigger,
- });
-
- const [checksTeam, checksCountTeam, isLoadingTeam, networkErrorTeam] =
- useFetchChecksTeam({
- status: false,
- sortOrder: "desc",
- limit: null,
- dateRange,
- filter: filter === "resolved" ? "all" : filter,
- ack: filter === "resolved" ? true : false,
- page: page,
- rowsPerPage: rowsPerPage,
- enabled: selectedMonitor === "0",
- updateTrigger,
- });
-
- const checks = selectedMonitor === "0" ? checksTeam : checksMonitor;
- const checksCount = selectedMonitor === "0" ? checksCountTeam : checksCountMonitor;
- isLoading = isLoadingTeam || isLoadingMonitor;
- const networkError = selectedMonitor === "0" ? networkErrorTeam : networkErrorMonitor;
-
- const { t } = useTranslation();
-
- //Handlers
- const handleChangePage = (_, newPage) => {
- setPage(newPage);
- };
-
- const handleChangeRowsPerPage = (event) => {
- setRowsPerPage(event.target.value);
- };
-
- const headers = [
- {
- id: "monitorName",
- content: t("incidentsTableMonitorName"),
- render: (row) => {
- return monitors?.[row.metadata?.monitorId]?.name || "N/A";
- },
- },
- {
- id: "status",
- content: t("incidentsTableStatus"),
- render: (row) => {
- const status = row.status === true ? "up" : "down";
- return (
-
- );
- },
- },
- {
- id: "dateTime",
- content: t("incidentsTableDateTime"),
- render: (row) => {
- const formattedDate = formatDateWithTz(
- row.createdAt,
- "YYYY-MM-DD HH:mm:ss A",
- uiTimezone
- );
- return formattedDate;
- },
- },
- {
- id: "statusCode",
- content: t("incidentsTableStatusCode"),
- render: (row) => ,
- },
- { id: "message", content: t("incidentsTableMessage"), render: (row) => row.message },
- ];
-
- if (isLoading) return ;
-
- if (networkError) {
- return (
-
-
-
- );
- }
-
- if (!isLoading && typeof checksCount === "undefined") {
- return {t("incidentsTableNoIncidents")};
- }
-
- return (
- <>
-
-
- >
- );
-};
-
-IncidentTable.propTypes = {
- isLoading: PropTypes.bool,
- monitors: PropTypes.object,
- selectedMonitor: PropTypes.string,
- filter: PropTypes.string,
- dateRange: PropTypes.string,
- updateTrigger: PropTypes.bool,
- setUpdateTrigger: PropTypes.func,
-};
-export default IncidentTable;
diff --git a/client/src/Pages/Checks/Components/OptionsHeader/index.jsx b/client/src/Pages/Checks/Components/OptionsHeader/index.jsx
deleted file mode 100644
index e04236a9b..000000000
--- a/client/src/Pages/Checks/Components/OptionsHeader/index.jsx
+++ /dev/null
@@ -1,139 +0,0 @@
-// Components
-import { Stack, Typography, Button, ButtonGroup } from "@mui/material";
-import Select from "@/Components/v1/Inputs/Select/index.jsx";
-import PropTypes from "prop-types";
-
-//Utils
-import { useTheme } from "@emotion/react";
-import SkeletonLayout from "./skeleton.jsx";
-import { useTranslation } from "react-i18next";
-
-const OptionsHeader = ({
- shouldRender,
- selectedMonitor = 0,
- setSelectedMonitor,
- monitors,
- filter = "all",
- setFilter,
- dateRange = "hour",
- setDateRange,
-}) => {
- const theme = useTheme();
- const { t } = useTranslation();
- const monitorNames = typeof monitors !== "undefined" ? Object.values(monitors) : [];
- const filterOptions = [
- { id: "all", name: t("incidentsOptionsHeaderFilterAll") },
- { id: "down", name: t("incidentsOptionsHeaderFilterDown") },
- { id: "resolve", name: t("incidentsOptionsHeaderFilterCannotResolve") },
- { id: "resolved", name: t("incidentsOptionsHeaderFilterResolved") },
- ];
-
- // The stacks below which are three in number have the same style so
- const stackStyles = {
- direction: "row",
- alignItems: "center",
- gap: theme.spacing(6),
- };
-
- if (!shouldRender) return ;
-
- return (
-
-
-
- {t("incidentsOptionsHeader")}
-
-
-
-
- {t("incidentsOptionsHeaderFilterBy")}
-
-
-
-
- {t("incidentsOptionsHeaderShow")}
-
-
-
-
-
-
-
-
-
- );
-};
-
-OptionsHeader.propTypes = {
- shouldRender: PropTypes.bool,
- selectedMonitor: PropTypes.string,
- setSelectedMonitor: PropTypes.func,
- monitors: PropTypes.object,
- filter: PropTypes.string,
- setFilter: PropTypes.func,
- dateRange: PropTypes.string,
- setDateRange: PropTypes.func,
-};
-
-export default OptionsHeader;
diff --git a/client/src/Pages/Checks/Components/OptionsHeader/skeleton.jsx b/client/src/Pages/Checks/Components/OptionsHeader/skeleton.jsx
deleted file mode 100644
index 8a8990dc4..000000000
--- a/client/src/Pages/Checks/Components/OptionsHeader/skeleton.jsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import { Stack, Skeleton } from "@mui/material";
-
-const SkeletonLayout = () => {
- return (
-
-
-
- );
-};
-
-export default SkeletonLayout;
diff --git a/client/src/Pages/Checks/Components/StatusBoxes/StatusBox.jsx b/client/src/Pages/Checks/Components/StatusBoxes/StatusBox.jsx
deleted file mode 100644
index d7f02ada3..000000000
--- a/client/src/Pages/Checks/Components/StatusBoxes/StatusBox.jsx
+++ /dev/null
@@ -1,129 +0,0 @@
-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 Icon from "@/Components/v1/Icon";
-
-const StatusBox = ({ title, value, status }) => {
- const theme = useTheme();
- let sharedStyles = {
- position: "absolute",
- right: 8,
- "& svg": {
- width: 20,
- height: 20,
- opacity: 0.9,
- "& path": { stroke: theme.palette.primary.contrastTextTertiary, strokeWidth: 1.7 },
- },
- };
-
- let color;
- let icon;
- if (status === "up") {
- color = theme.palette.success.lowContrast;
- icon = (
-
-
-
- );
- } else if (status === "down") {
- color = theme.palette.error.lowContrast;
- icon = (
-
-
-
- );
- } else if (status === "paused") {
- color = theme.palette.warning.lowContrast;
- icon = (
-
-
-
- );
- } else {
- color = theme.palette.accent.main;
- icon = (
-
-
-
- );
- }
-
- return (
-
-
-
-
-
-
-
- {title}
-
- {icon}
-
-
- {value}
-
-
- #
-
-
-
-
- );
-};
-
-StatusBox.propTypes = {
- title: PropTypes.string.isRequired,
- value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
- status: PropTypes.string,
-};
-
-export default StatusBox;
diff --git a/client/src/Pages/Checks/Components/StatusBoxes/index.jsx b/client/src/Pages/Checks/Components/StatusBoxes/index.jsx
deleted file mode 100644
index bb993111a..000000000
--- a/client/src/Pages/Checks/Components/StatusBoxes/index.jsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import PropTypes from "prop-types";
-import { Stack } from "@mui/material";
-import StatusBox from "./StatusBox.jsx";
-import { useTheme } from "@emotion/react";
-import { useTranslation } from "react-i18next";
-import SkeletonLayout from "./skeleton.jsx";
-
-const StatusBoxes = ({ isLoading, summary }) => {
- const theme = useTheme();
- const { t } = useTranslation();
- if (isLoading) return ;
- return (
-
-
-
-
-
-
- );
-};
-
-StatusBoxes.propTypes = {
- isLoading: PropTypes.bool,
- summary: PropTypes.object,
-};
-
-export default StatusBoxes;
diff --git a/client/src/Pages/Checks/Components/StatusBoxes/skeleton.jsx b/client/src/Pages/Checks/Components/StatusBoxes/skeleton.jsx
deleted file mode 100644
index b9aa016b7..000000000
--- a/client/src/Pages/Checks/Components/StatusBoxes/skeleton.jsx
+++ /dev/null
@@ -1,36 +0,0 @@
-import { Skeleton, Stack } from "@mui/material";
-import { useTheme } from "@emotion/react";
-
-const SkeletonLayout = () => {
- const theme = useTheme();
- return (
-
-
-
-
-
-
- );
-};
-
-export default SkeletonLayout;
diff --git a/client/src/Pages/Checks/old.jsx b/client/src/Pages/Checks/old.jsx
deleted file mode 100644
index bcd036a58..000000000
--- a/client/src/Pages/Checks/old.jsx
+++ /dev/null
@@ -1,100 +0,0 @@
-// Components
-import { Stack } from "@mui/material";
-import Breadcrumbs from "@/Components/v1/Breadcrumbs/index.jsx";
-import GenericFallback from "@/Components/v1/GenericFallback/index.jsx";
-import IncidentTable from "./Components/IncidentTable/index.jsx";
-import OptionsHeader from "./Components/OptionsHeader/index.jsx";
-import StatusBoxes from "./Components/StatusBoxes/index.jsx";
-
-//Utils
-import { useTheme } from "@emotion/react";
-import { useFetchMonitorsByTeamId } from "@/Hooks/monitorHooks.js";
-import { useFetchChecksSummaryByTeamId } from "@/Hooks/checkHooks.js";
-import { useState, useEffect } from "react";
-import NetworkError from "@/Components/v1/GenericFallback/NetworkError.jsx";
-import { useTranslation } from "react-i18next";
-import { useParams } from "react-router-dom";
-
-//Constants
-const Checks = () => {
- // Redux state
- const { t } = useTranslation();
-
- const BREADCRUMBS = [{ name: t("checksPageTitle"), path: "/checks" }];
-
- // Local state
- const [selectedMonitor, setSelectedMonitor] = useState("0");
- const [filter, setFilter] = useState(undefined);
- const [dateRange, setDateRange] = useState("hour");
- const [monitorLookup, setMonitorLookup] = useState(undefined);
- const [updateTrigger, setUpdateTrigger] = useState(false);
-
- //Hooks
-
- //Utils
- const theme = useTheme();
- const [monitors, , isLoading, networkError] = useFetchMonitorsByTeamId({});
- const [summary, isLoadingSummary, networkErrorSummary] = useFetchChecksSummaryByTeamId({
- dateRange,
- updateTrigger,
- });
- const { monitorId } = useParams();
-
- useEffect(() => {
- if (monitorId) {
- setSelectedMonitor(monitorId);
- }
- }, [monitorId]);
-
- useEffect(() => {
- const monitorLookup = monitors?.reduce((acc, monitor) => {
- acc[monitor.id] = {
- id: monitor.id,
- name: monitor.name,
- type: monitor.type,
- };
- return acc;
- }, {});
- setMonitorLookup(monitorLookup);
- }, [monitors]);
-
- if (networkError || networkErrorSummary) {
- return (
-
-
-
- );
- }
-
- return (
-
-
-
-
-
-
-
- );
-};
-
-export default Checks;
diff --git a/client/src/Pages/PageSpeed/Details/Components/Charts/AreaChart.jsx b/client/src/Pages/PageSpeed/Details/Components/Charts/AreaChart.jsx
deleted file mode 100644
index d8c118237..000000000
--- a/client/src/Pages/PageSpeed/Details/Components/Charts/AreaChart.jsx
+++ /dev/null
@@ -1,330 +0,0 @@
-import PropTypes from "prop-types";
-import {
- AreaChart,
- Area,
- XAxis,
- Tooltip,
- CartesianGrid,
- ResponsiveContainer,
- Text,
-} from "recharts";
-import { useTheme } from "@emotion/react";
-import { useMemo, useState } from "react";
-import { Box, Stack, Typography } from "@mui/material";
-import { formatDateWithTz } from "../../../../../Utils/timeUtilsLegacy.js";
-import { useSelector } from "react-redux";
-
-const config = {
- seo: {
- id: "seo",
- text: "SEO",
- color: "secondary",
- },
- performance: {
- id: "performance",
- text: "performance",
- color: "success",
- },
- bestPractices: {
- id: "bestPractices",
- text: "best practices",
- color: "warning",
- },
- accessibility: {
- id: "accessibility",
- text: "accessibility",
- color: "accent",
- },
-};
-
-/**
- * Custom tooltip for the area chart.
- * @param {Object} props
- * @param {boolean} props.active - Whether the tooltip is active.
- * @param {Array} props.payload - The payload data for the tooltip.
- * @param {string} props.label - The label for the tooltip.
- * @returns {JSX.Element|null} The tooltip element or null if not active.
- */
-
-const CustomToolTip = ({ active, payload, label, config }) => {
- const theme = useTheme();
- const uiTimezone = useSelector((state) => state.ui.timezone);
-
- if (active && payload && payload.length) {
- return (
-
-
- {formatDateWithTz(label, "ddd, MMMM D, YYYY, h:mm A", uiTimezone)}
-
- {Object.keys(config)
- .reverse()
- .map((key) => {
- const { color } = config[key];
- const dotColor = theme.palette[color].main;
-
- return (
-
-
-
- {config[key].text}
- {" "}
- {payload[0].payload[key]}
-
- );
- })}
-
- );
- }
- return null;
-};
-
-CustomToolTip.propTypes = {
- active: PropTypes.bool,
- payload: PropTypes.array,
- label: PropTypes.string,
- config: PropTypes.object,
-};
-
-/**
- * Processes data to insert gaps with null values based on the interval.
- * @param {Array} data
- * @param {number} interval - The interval in milliseconds for gaps.
- * @returns {Array} The formatted data with gaps.
- */
-const processDataWithGaps = (data, interval) => {
- if (data.length === 0) return [];
- let formattedData = [];
- let last = new Date(data[0].createdAt).getTime();
-
- // Helper function to add a null entry
- const addNullEntry = (timestamp) => {
- formattedData.push({
- accessibility: "N/A",
- bestPractices: "N/A",
- performance: "N/A",
- seo: "N/A",
- createdAt: timestamp,
- });
- };
-
- data.forEach((entry) => {
- const current = new Date(entry.createdAt).getTime();
-
- if (current - last > interval * 2) {
- // Insert null entries for each interval
- let temp = last + interval;
- while (temp < current) {
- addNullEntry(new Date(temp).toISOString());
- temp += interval;
- }
- }
-
- formattedData.push(entry);
- last = current;
- });
-
- return formattedData;
-};
-
-/**
- * Custom tick component to render ticks on the XAxis.
- *
- * @param {Object} props
- * @param {number} props.x - The x coordinate for the tick.
- * @param {number} props.y - The y coordinate for the tick.
- * @param {Object} props.payload - The data object containing the tick value.
- * @param {number} props.index - The index of the tick in the array of ticks.
- *
- * @returns {JSX.Element|null} The tick element or null if the tick should be hidden.
- */
-const CustomTick = ({ x, y, payload, index }) => {
- const theme = useTheme();
- const uiTimezone = useSelector((state) => state.ui.timezone);
-
- // Render nothing for the first tick
- if (index === 0) return null;
-
- return (
-
- {formatDateWithTz(payload?.value, "h:mm a", uiTimezone)}
-
- );
-};
-CustomTick.propTypes = {
- x: PropTypes.number,
- y: PropTypes.number,
- payload: PropTypes.shape({
- value: PropTypes.string.isRequired,
- }),
- index: PropTypes.number,
-};
-
-/**
- * A chart displaying pagespeed details over time.
- * @param {Object} props
- * @param {Array} props.data - The data to display in the chart.
- * @param {number} props.interval - The interval in milliseconds for processing gaps.
- * @returns {JSX.Element} The area chart component.
- */
-
-const PageSpeedAreaChart = ({ data, monitor, metrics }) => {
- const theme = useTheme();
- const [isHovered, setIsHovered] = useState(false);
- const memoizedData = useMemo(
- () => processDataWithGaps(data, monitor.interval),
- [data[0]]
- );
-
- const filteredConfig = Object.keys(config).reduce((result, key) => {
- if (metrics[key]) {
- result[key] = config[key];
- }
- return result;
- }, {});
-
- return (
-
- setIsHovered(true)}
- onMouseLeave={() => setIsHovered(false)}
- >
-
- }
- axisLine={false}
- tickLine={false}
- height={18}
- minTickGap={0}
- interval="equidistantPreserveStart"
- />
- }
- />
-
- {Object.values(filteredConfig).map(({ id, color }) => {
- /* TODO not working? */
- const startColor = theme.palette[color].main;
- const endColor = theme.palette[color].lowContrast;
-
- return (
-
-
-
-
- );
- })}
-
- {Object.keys(filteredConfig).map((key) => {
- const { color } = filteredConfig[key];
- const strokeColor = theme.palette[color].main;
- const bgColor = theme.palette.primary.main;
-
- return (
-
- );
- })}
-
-
- );
-};
-
-PageSpeedAreaChart.propTypes = {
- data: PropTypes.arrayOf(
- PropTypes.shape({
- createdAt: PropTypes.string.isRequired,
- accessibility: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
- bestPractices: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
- performance: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
- seo: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
- })
- ).isRequired,
- monitor: PropTypes.object.isRequired,
- metrics: PropTypes.object,
-};
-
-export default PageSpeedAreaChart;
diff --git a/client/src/Pages/PageSpeed/Details/Components/Charts/AreaChartLegend.jsx b/client/src/Pages/PageSpeed/Details/Components/Charts/AreaChartLegend.jsx
deleted file mode 100644
index 525e4d0d2..000000000
--- a/client/src/Pages/PageSpeed/Details/Components/Charts/AreaChartLegend.jsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import { Box, Typography, Divider } from "@mui/material";
-import Checkbox from "@/Components/v1/Inputs/Checkbox/index.jsx";
-import Icon from "@/Components/v1/Icon";
-import LegendBox from "@/Components/v1/Charts/LegendBox/index.jsx";
-import { useTranslation } from "react-i18next";
-import { useTheme } from "@emotion/react";
-
-const AreaChartLegend = ({ metrics, handleMetrics }) => {
- const theme = useTheme();
- const { t } = useTranslation();
- return (
-
- }
- header="Metrics"
- >
-
-
- {t("shown")}
-
-
-
- handleMetrics("accessibility")}
- />
-
- handleMetrics("bestPractices")}
- />
-
- handleMetrics("performance")}
- />
-
- handleMetrics("seo")}
- />
-
-
- );
-};
-
-export default AreaChartLegend;
diff --git a/client/src/Pages/PageSpeed/Details/Components/Charts/PieChart.jsx b/client/src/Pages/PageSpeed/Details/Components/Charts/PieChart.jsx
deleted file mode 100644
index eec075684..000000000
--- a/client/src/Pages/PageSpeed/Details/Components/Charts/PieChart.jsx
+++ /dev/null
@@ -1,327 +0,0 @@
-import PropTypes from "prop-types";
-import { PieChart as MuiPieChart } from "@mui/x-charts/PieChart";
-import { useDrawingArea } from "@mui/x-charts";
-import { useState } from "react";
-import { useTheme } from "@emotion/react";
-import { Box } from "@mui/material";
-
-/**
- * Renders a centered label within a pie chart.
- *
- * @param {Object} props
- * @param {string | number} props.value - The value to display in the label.
- * @param {string} props.color - The color of the text.
- * @returns {JSX.Element}
- */
-const PieCenterLabel = ({ value, color, setExpand }) => {
- const { width, height } = useDrawingArea();
- return (
- setExpand(true)}
- >
-
-
- {value}
-
-
- );
-};
-
-PieCenterLabel.propTypes = {
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
- color: PropTypes.string,
- setExpand: PropTypes.func,
-};
-
-/**
- * A component that renders a label on a pie chart slice.
- * The label is positioned relative to the center of the pie chart and is optionally highlighted.
- *
- * @param {Object} props
- * @param {number} props.value - The value to display inside the pie slice.
- * @param {number} props.startAngle - The starting angle of the pie slice in degrees.
- * @param {number} props.endAngle - The ending angle of the pie slice in degrees.
- * @param {string} props.color - The color of the label text when highlighted.
- * @param {boolean} props.highlighted - Determines if the label should be highlighted or not.
- * @returns {JSX.Element}
- */
-const PieValueLabel = ({ value, startAngle, endAngle, color, highlighted }) => {
- const { width, height } = useDrawingArea();
-
- // Compute the midpoint angle in radians
- const angle = (((startAngle + endAngle) / 2) * Math.PI) / 180;
- const radius = height / 4; // length from center of the circle to where the text is positioned
-
- // Calculate x and y positions
- const x = Math.sin(angle) * radius;
- const y = -Math.cos(angle) * radius;
-
- return (
-
-
- +{value}
-
-
- );
-};
-
-// Validate props using PropTypes
-PieValueLabel.propTypes = {
- value: PropTypes.number.isRequired,
- startAngle: PropTypes.number.isRequired,
- endAngle: PropTypes.number.isRequired,
- color: PropTypes.string.isRequired,
- highlighted: PropTypes.bool.isRequired,
-};
-
-/**
- * Weight constants for different performance metrics.
- * @type {Object}
- */
-const weights = {
- fcp: 10,
- si: 10,
- lcp: 25,
- tbt: 30,
- cls: 25,
-};
-
-const PieChart = ({ audits }) => {
- const theme = useTheme();
- const [highlightedItem, setHighLightedItem] = useState(null);
- const [expand, setExpand] = useState(false);
-
- /**
- * Retrieves color properties based on the performance value.
- *
- * @param {number} value - The performance score used to determine the color properties.
- * @returns {{stroke: string, strokeBg: string, text: string, bg: string}} The color properties for the given performance value.
- */
- const getColors = (value) => {
- if (value >= 90 && value <= 100)
- return {
- stroke: theme.palette.success.main,
- strokeBg: theme.palette.success.lowContrast,
- text: theme.palette.success.contrastText,
- bg: theme.palette.success.lowContrast,
- };
- else if (value >= 50 && value < 90)
- return {
- stroke: theme.palette.warning.main,
- strokeBg: theme.palette.warning.lowContrast,
- text: theme.palette.warning.contrastText,
- bg: theme.palette.warning.lowContrast,
- };
- else if (value >= 0 && value < 50)
- return {
- stroke: theme.palette.error.contrastText,
- strokeBg: theme.palette.error.lowContrast,
- text: theme.palette.error.contrastText,
- bg: theme.palette.error.lowContrast,
- };
- return {
- stroke: theme.palette.tertiary.contrastText,
- strokeBg: theme.palette.tertiary.contrastText,
- text: theme.palette.tertiary.contrastText,
- bg: theme.palette.tertiary.main,
- };
- };
-
- /**
- * Calculates and formats the data needed for rendering a pie chart based on audit scores and weights.
- * This function generates properties for each pie slice, including angles, radii, and colors.
- * It also calculates performance based on the weighted values.
- *
- * @returns {Array