diff --git a/Client/src/Pages/PageSpeed/Details/index.jsx b/Client/src/Pages/PageSpeed/Details/index.jsx index ad3b66abc..7e24372f3 100644 --- a/Client/src/Pages/PageSpeed/Details/index.jsx +++ b/Client/src/Pages/PageSpeed/Details/index.jsx @@ -1,4 +1,4 @@ -import { Box, Stack, Typography } from "@mui/material"; +import { Box, Skeleton, Stack, Typography } from "@mui/material"; import { PieChart } from "@mui/x-charts/PieChart"; import { useDrawingArea } from "@mui/x-charts"; import { useEffect, useState } from "react"; @@ -136,17 +136,22 @@ const PageSpeedDetails = () => { useEffect(() => { const fetchMonitor = async () => { - const res = await axiosInstance.get( - `/monitors/${monitorId}?sortOrder=desc`, - { - headers: { - Authorization: `Bearer ${authToken}`, - }, - } - ); + try { + const res = await axiosInstance.get( + `/monitors/${monitorId}?sortOrder=desc`, + { + headers: { + Authorization: `Bearer ${authToken}`, + }, + } + ); - setMonitor(res.data.data); - setAudits(res.data.data.checks[0].audits); + setMonitor(res.data.data); + setAudits(res.data.data.checks[0].audits); + } catch (error) { + console.error("Error fetching pagespeed monitor of id: " + monitorId); + navigate("/not-found"); + } }; fetchMonitor(); @@ -244,61 +249,93 @@ const PageSpeedDetails = () => { const [highlightedItem, setHighLightedItem] = useState(null); const [expand, setExpand] = useState(false); + let loading = Object.keys(monitor).length === 0; + return ( -