import { useState, useEffect } from "react";
import { useSelector } from "react-redux";
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";
import BasicTable from "../../Components/BasicTable";
import { StatusLabel } from "../../Components/Label";
import { useTheme } from "@emotion/react";
import { useNavigate } from "react-router";
import Select from "../../Components/Inputs/Select";
import IncidentTable from "./IncidentTable";
import "./index.css";
/**
* Renders a skeleton layout.
*
* @returns {JSX.Element}
*/
const SkeletonLayout = () => {
const theme = useTheme();
return (
<>
>
);
};
const Incidents = () => {
const theme = useTheme();
const navigate = useNavigate();
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");
useEffect(() => {
const fetchMonitors = async () => {
setLoading(true);
const res = await axiosInstance.get(
`/monitors/user/${authState.user._id}?status=false&limit=1`,
{
headers: {
Authorization: `Bearer ${authState.authToken}`,
},
}
);
// Reduce to a lookup object for 0(1) lookup
if (res.data && res.data.data.length > 0) {
const monitorLookup = res.data.data.reduce((acc, monitor) => {
acc[monitor._id] = monitor;
return acc;
}, {});
setMonitors(monitorLookup);
}
setLoading(false);
};
fetchMonitors();
}, [authState]);
useEffect(() => {}, []);
const handleSelect = (event) => {
setSelectedMonitor(event.target.value);
};
return (
// <>
//
// {loading ? (
//
// ) : false ? (
// <>
//
// Incident history for:
//
// {hasAnyIncidents && hasSpecificIncidents && (
//
// setFilter("all")}
// sx={{
// backgroundColor:
// filter === "all" && theme.palette.otherColors.fillGray,
// }}
// />
// setFilter("down")}
// sx={{
// backgroundColor:
// filter === "down" && theme.palette.otherColors.fillGray,
// }}
// />
// setFilter("resolve")}
// sx={{
// backgroundColor:
// filter === "resolve" &&
// theme.palette.otherColors.fillGray,
// }}
// />
//
// )}
//
// {hasAnyIncidents && hasSpecificIncidents ? (
// thing
// ) : (
//
// The monitor you have selected, has no recorded incidents yet.
//
// )}
// >
// ) : (
//
// }
// onClick={() => navigate(-1)}
// sx={{
// backgroundColor: theme.palette.otherColors.fillGray,
// px: theme.gap.ml,
// mb: theme.gap.ml,
// "& svg.MuiSvgIcon-root": {
// mr: theme.gap.small,
// fill: theme.palette.otherColors.slateGray,
// },
// }}
// />
//
// No incidents, yet.
//
//
// )}
//
// >
);
};
export default Incidents;