safe param access
This commit is contained in:
1 parent
4c3b348642
commit
80a16ef61a
5 files changed
+6
-17
No files matched your search
@@ -118,8 +118,6 @@ const PieChart = ({ audits }) => {
|
|||||||
const [highlightedItem, setHighLightedItem] = useState(null);
|
const [highlightedItem, setHighLightedItem] = useState(null);
|
||||||
const [expand, setExpand] = useState(false);
|
const [expand, setExpand] = useState(false);
|
||||||
|
|
||||||
if (typeof audits === "undefined") return null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves color properties based on the performance value.
|
* Retrieves color properties based on the performance value.
|
||||||
*
|
*
|
||||||
@@ -166,6 +164,8 @@ const PieChart = ({ audits }) => {
|
|||||||
*/
|
*/
|
||||||
let performance = 0;
|
let performance = 0;
|
||||||
const getPieData = (audits) => {
|
const getPieData = (audits) => {
|
||||||
|
if (typeof audits === "undefined") return undefined;
|
||||||
|
|
||||||
let data = [];
|
let data = [];
|
||||||
let startAngle = 0;
|
let startAngle = 0;
|
||||||
const padding = 3; // padding between arcs
|
const padding = 3; // padding between arcs
|
||||||
|
|||||||
@@ -7,14 +7,14 @@ import PropTypes from "prop-types";
|
|||||||
const PieChartLegend = ({ audits }) => {
|
const PieChartLegend = ({ audits }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
if (typeof audits === "undefined") return null;
|
|
||||||
return (
|
return (
|
||||||
<LegendBox
|
<LegendBox
|
||||||
icon={<SpeedometerIcon />}
|
icon={<SpeedometerIcon />}
|
||||||
header="Performance metrics"
|
header="Performance metrics"
|
||||||
sx={{ flex: 1 }}
|
sx={{ flex: 1 }}
|
||||||
>
|
>
|
||||||
{Object.keys(audits).map((key) => {
|
{typeof audits !== "undefined" &&
|
||||||
|
Object.keys(audits).map((key) => {
|
||||||
if (key === "_id") return;
|
if (key === "_id") return;
|
||||||
|
|
||||||
let audit = audits[key];
|
let audit = audits[key];
|
||||||
|
|||||||
@@ -15,10 +15,6 @@ const PageSpeedAreaChart = ({ shouldRender, monitor, metrics, handleMetrics }) =
|
|||||||
return <SkeletonLayout />;
|
return <SkeletonLayout />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof monitor === "undefined") {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = monitor?.checks ? [...monitor.checks].reverse() : [];
|
const data = monitor?.checks ? [...monitor.checks].reverse() : [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -5,18 +5,14 @@ import { Typography } from "@mui/material";
|
|||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import PieChartLegend from "../Charts/PieChartLegend";
|
import PieChartLegend from "../Charts/PieChartLegend";
|
||||||
import SkeletonLayout from "./skeleton";
|
import SkeletonLayout from "./skeleton";
|
||||||
|
|
||||||
const PerformanceReport = ({ shouldRender, audits }) => {
|
const PerformanceReport = ({ shouldRender, audits }) => {
|
||||||
console.log("shouldRender", shouldRender);
|
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
if (!shouldRender) {
|
if (!shouldRender) {
|
||||||
return <SkeletonLayout />;
|
return <SkeletonLayout />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof audits === "undefined") {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ChartBox
|
<ChartBox
|
||||||
icon={<PerformanceIcon />}
|
icon={<PerformanceIcon />}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
// Components
|
// Components
|
||||||
import { Stack, Typography } from "@mui/material";
|
import { Stack, Typography, Skeleton } from "@mui/material";
|
||||||
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
||||||
import MonitorStatusHeader from "../../../Components/MonitorStatusHeader";
|
import MonitorStatusHeader from "../../../Components/MonitorStatusHeader";
|
||||||
import PageSpeedStatusBoxes from "./Components/PageSpeedStatusBoxes";
|
import PageSpeedStatusBoxes from "./Components/PageSpeedStatusBoxes";
|
||||||
import PageSpeedAreaChart from "./Components/PageSpeedAreaChart";
|
import PageSpeedAreaChart from "./Components/PageSpeedAreaChart";
|
||||||
import PerformanceReport from "./Components/PerformanceReport";
|
import PerformanceReport from "./Components/PerformanceReport";
|
||||||
import Fallback from "../../../Components/Fallback";
|
|
||||||
// Utils
|
// Utils
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
||||||
@@ -31,8 +30,6 @@ const PageSpeedDetails = () => {
|
|||||||
monitorId,
|
monitorId,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(monitor, audits, isLoading);
|
|
||||||
|
|
||||||
const [metrics, setMetrics] = useState({
|
const [metrics, setMetrics] = useState({
|
||||||
accessibility: true,
|
accessibility: true,
|
||||||
bestPractices: true,
|
bestPractices: true,
|
||||||
|
|||||||
Reference in new issue
Block a user