// 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"; import Breadcrumbs from "../../../Components/Breadcrumbs/index.jsx"; // 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"; import { useTranslation } from "react-i18next"; const PublicStatus = () => { const { url } = useParams(); // Local state const [isDeleteOpen, setIsDeleteOpen] = useState(false); // Utils const theme = useTheme(); const { t } = useTranslation(); const location = useLocation(); const navigate = useNavigate(); const [statusPage, monitors, isLoading, networkError, fetchStatusPage] = useStatusPageFetch(false, url); const [deleteStatusPage, isDeleting] = useStatusPageDelete(fetchStatusPage, url); // Breadcrumbs const crumbs = [ { name: t("statusBreadCrumbsStatusPages"), path: "/status" }, { name: t("statusBreadCrumbsDetails"), path: `/status/uptime/${statusPage?.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 ( {t("common.toasts.networkError")} {t("common.toasts.checkConnection")} ); } // Public status page fallback if (!isLoading && typeof statusPage === "undefined" && isPublic) { return ( {t("statusPageStatus")} {t("statusPageStatusContactAdmin")} ); } // Finished loading, but status page is not public if (!isLoading && isPublic && statusPage.isPublished === false) { return ( {t("statusPageStatusNotPublic")} {t("statusPageStatusContactAdmin")} ); } // Status page doesn't exist if (!isLoading && typeof statusPage === "undefined") { return ( {t("statusPageStatusNoPage")} {t("statusPageStatusContactAdmin")} ); } return ( {!isPublic && } {t("statusPageStatusServiceStatus")} {link} { deleteStatusPage(); setIsDeleteOpen(false); navigate("/status"); }} onCancel={() => { setIsDeleteOpen(false); }} open={isDeleteOpen} confirmationButtonLabel={t("deleteStatusPageConfirm")} description={t("deleteStatusPageDescription")} isLoading={isDeleting || isLoading} /> ); }; export default PublicStatus;