2025-01-29 15:06:41 -08:00
|
|
|
// Components
|
|
|
|
|
import { Stack } from "@mui/material";
|
|
|
|
|
import Breadcrumbs from "../../Components/Breadcrumbs";
|
2024-09-13 11:23:03 +08:00
|
|
|
|
2025-01-29 15:06:41 -08:00
|
|
|
//Utils
|
2024-07-23 17:32:41 -04:00
|
|
|
import { useTheme } from "@emotion/react";
|
2025-01-29 15:06:41 -08:00
|
|
|
import { useMonitorsFetch } from "./Hooks/useMonitorsFetch";
|
|
|
|
|
import { useSelector } from "react-redux";
|
|
|
|
|
import OptionsHeader from "./Components/OptionsHeader";
|
|
|
|
|
import { useState } from "react";
|
|
|
|
|
import IncidentTable from "./Components/IncidentTable";
|
|
|
|
|
import GenericFallback from "../../Components/GenericFallback";
|
|
|
|
|
import NetworkError from "../../Components/GenericFallback/NetworkError";
|
2025-05-12 20:30:54 -04:00
|
|
|
import { useTranslation } from "react-i18next";
|
2025-01-29 15:06:41 -08:00
|
|
|
//Constants
|
2024-08-07 19:49:08 -04:00
|
|
|
|
2024-07-22 11:28:39 -07:00
|
|
|
const Incidents = () => {
|
2025-01-29 15:06:41 -08:00
|
|
|
// Redux state
|
2025-02-18 04:56:26 +00:00
|
|
|
const { user } = useSelector((state) => state.auth);
|
2025-05-12 20:30:54 -04:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
|
|
const BREADCRUMBS = [{ name: t("incidentsPageTitle", "Incidents"), path: "/incidents" }];
|
2024-08-08 14:56:26 -07:00
|
|
|
|
2025-01-29 15:06:41 -08:00
|
|
|
// Local state
|
2024-10-18 18:38:08 -04:00
|
|
|
const [selectedMonitor, setSelectedMonitor] = useState("0");
|
2025-01-29 15:06:41 -08:00
|
|
|
const [filter, setFilter] = useState(undefined);
|
|
|
|
|
const [dateRange, setDateRange] = useState(undefined);
|
|
|
|
|
//Utils
|
|
|
|
|
const theme = useTheme();
|
2024-07-22 15:44:40 -07:00
|
|
|
|
2025-01-29 15:06:41 -08:00
|
|
|
const { monitors, isLoading, networkError } = useMonitorsFetch({
|
|
|
|
|
teamId: user.teamId,
|
|
|
|
|
});
|
2024-08-08 16:13:08 -07:00
|
|
|
|
2025-01-29 15:06:41 -08:00
|
|
|
if (networkError) {
|
|
|
|
|
return (
|
|
|
|
|
<GenericFallback>
|
|
|
|
|
<NetworkError />
|
|
|
|
|
</GenericFallback>
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-07-22 15:44:40 -07:00
|
|
|
|
2024-10-18 18:38:08 -04:00
|
|
|
return (
|
2025-01-29 15:06:41 -08:00
|
|
|
<Stack gap={theme.spacing(10)}>
|
|
|
|
|
<Breadcrumbs list={BREADCRUMBS} />
|
|
|
|
|
<OptionsHeader
|
|
|
|
|
shouldRender={!isLoading}
|
|
|
|
|
monitors={monitors}
|
|
|
|
|
selectedMonitor={selectedMonitor}
|
|
|
|
|
setSelectedMonitor={setSelectedMonitor}
|
|
|
|
|
filter={filter}
|
|
|
|
|
setFilter={setFilter}
|
|
|
|
|
dateRange={dateRange}
|
|
|
|
|
setDateRange={setDateRange}
|
|
|
|
|
/>
|
|
|
|
|
<IncidentTable
|
|
|
|
|
shouldRender={!isLoading}
|
|
|
|
|
monitors={monitors}
|
|
|
|
|
selectedMonitor={selectedMonitor}
|
|
|
|
|
filter={filter}
|
|
|
|
|
dateRange={dateRange}
|
|
|
|
|
/>
|
2024-10-18 18:38:08 -04:00
|
|
|
</Stack>
|
|
|
|
|
);
|
2024-07-22 11:28:39 -07:00
|
|
|
};
|
2024-07-02 20:43:39 -07:00
|
|
|
|
2024-07-22 11:28:39 -07:00
|
|
|
export default Incidents;
|