// Components
import { Typography, Stack } from "@mui/material";
import GenericFallback from "../../../Components/GenericFallback";
import AdminLink from "./Components/AdminLink";
import ControlsHeader from "./Components/ControlsHeader";
import SkeletonLayout from "./Components/Skeleton";
import StatusBar from "./Components/StatusBar";
import MonitorsList from "./Components/MonitorsList";
import Dialog from "../../../Components/Dialog";
// Utils
import { useStatusPageFetch } from "./Hooks/useStatusPageFetch";
import { useTheme } from "@emotion/react";
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
import { useLocation } from "react-router-dom";
import { useStatusPageDelete } from "./Hooks/useStatusPageDelete";
import { useState } from "react";
import { useParams } from "react-router-dom";
import { useNavigate } from "react-router-dom";
const PublicStatus = () => {
const { url } = useParams();
// Local state
const [isDeleteOpen, setIsDeleteOpen] = useState(false);
// Utils
const theme = useTheme();
const location = useLocation();
const navigate = useNavigate();
const [statusPage, monitors, isLoading, networkError, fetchStatusPage] =
useStatusPageFetch(false, url);
const [deleteStatusPage, isDeleting] = useStatusPageDelete(fetchStatusPage, url);
// Setup
let sx = { paddingLeft: theme.spacing(20), paddingRight: theme.spacing(20) };
let link = undefined;
const isPublic = location.pathname.startsWith("/status/uptime/public");
// Public status page
if (isPublic) {
sx = {
paddingTop: theme.spacing(20),
paddingLeft: "20vw",
paddingRight: "20vw",
};
link = ;
}
// Loading
if (isLoading) {
return ;
}
// Error fetching data
if (networkError === true) {
return (
Network error
Please check your connection
);
}
// Public status page fallback
if (!isLoading && typeof statusPage === "undefined" && isPublic) {
return (
A public status page is not set up.
Please contact to your administrator
);
}
// Finished loading, but status page is not public
if (!isLoading && isPublic && statusPage.isPublished === false) {
return (
This status page is not public.
Please contact to your administrator
);
}
// Status page doesn't exist
if (!isLoading && typeof statusPage === "undefined") {
return (
There's no status page here.
Please contact to your administrator
);
}
return (
Service status
{link}
);
};
export default PublicStatus;