diff --git a/Client/src/Pages/Incidents/index.jsx b/Client/src/Pages/Incidents/index.jsx index e245e0b6c..399a0a3bc 100644 --- a/Client/src/Pages/Incidents/index.jsx +++ b/Client/src/Pages/Incidents/index.jsx @@ -1,6 +1,6 @@ import { useState, useEffect } from "react"; import { useSelector } from "react-redux"; -import { Typography, ButtonGroup, Stack, Box } from "@mui/material"; +import { Typography, ButtonGroup, Stack, Box, Skeleton } from "@mui/material"; import WestRoundedIcon from "@mui/icons-material/WestRounded"; import Button from "../../Components/Button"; import axiosInstance from "../../Utils/axiosConfig"; @@ -18,6 +18,7 @@ const Incidents = () => { const authState = useSelector((state) => state.auth); const [monitors, setMonitors] = useState({}); const [selectedMonitor, setSelectedMonitor] = useState("0"); + const [loading, setLoading] = useState(false); // TODO do something with these filters const [filter, setFilter] = useState("all"); @@ -34,6 +35,7 @@ const Incidents = () => { useEffect(() => { const fetchIncidents = async () => { + setLoading(true); const res = await axiosInstance.get( `/monitors/user/${authState.user._id}?status=false`, { @@ -51,6 +53,7 @@ const Incidents = () => { }, {}); setMonitors(monitorLookup); } + setLoading(false); }; fetchIncidents(); @@ -92,8 +95,8 @@ const Incidents = () => { data: , }, { id: idx + 1, data: new Date(incident.createdAt).toLocaleString() }, - { id: idx + 2, data: incident.statusCode }, - { id: idx + 3, data: monitors[incident.monitorId].name }, + { id: idx + 2, data: monitors[incident.monitorId].name }, + { id: idx + 3, data: incident.statusCode }, ], }; }); @@ -102,7 +105,22 @@ const Incidents = () => { return ( <> - {hasAnyIncidents ? ( + {loading ? ( + <> + + + + + + + + + ) : hasAnyIncidents ? ( <> Incident history for: @@ -155,8 +173,7 @@ const Incidents = () => { )} ) : ( - - No incidents, yet. +