import { BasePage, BaseFallback } from "@/Components/design-elements"; import Typography from "@mui/material/Typography"; import { Link } from "react-router-dom"; import Stack from "@mui/material/Stack"; import { useTheme } from "@mui/material"; import { useTranslation } from "react-i18next"; import { useIsAdmin } from "@/Hooks/useIsAdmin"; import { useLocation, useParams } from "react-router-dom"; import { useGet } from "@/Hooks/UseApi"; import type { Monitor } from "@/Types/Monitor"; import type { StatusPage, StatusPageResponse, StatusPageTheme } from "@/Types/StatusPage"; import { resolveStatusPageTheme } from "@/Types/StatusPage"; import { HeaderStatusPageControls } from "./Components/HeaderStatusPageControls"; import { StatusPageThemeProvider } from "./themes/StatusPageThemeProvider"; import { RefinedStatusPage } from "./themes/refined/RefinedStatusPage"; import { ModernStatusPage } from "./themes/modern/ModernStatusPage"; import { BoldStatusPage } from "./themes/bold/BoldStatusPage"; import { EditorialStatusPage } from "./themes/editorial/EditorialStatusPage"; import { BrowserFrame } from "./themes/BrowserFrame"; type ThemedRendererProps = { statusPage: StatusPage; monitors: (Monitor & { checks?: Monitor["recentChecks"] })[]; }; const THEMED_RENDERERS: Record< StatusPageTheme, React.ComponentType > = { refined: RefinedStatusPage, modern: ModernStatusPage, bold: BoldStatusPage, editorial: EditorialStatusPage, }; const StatusPageView = () => { const theme = useTheme(); const { t } = useTranslation(); const { url } = useParams(); const isAdmin = useIsAdmin(); const location = useLocation(); const isPublic = location.pathname.startsWith("/status/public"); const apiUrl = url ? `/status-page/${url}?type=uptime&type=infrastructure` : null; const { data, isLoading, error } = useGet( apiUrl, {}, { refreshInterval: 10000, } ); const statusPage = data?.statusPage; const monitors = data?.monitors ?? []; if (!statusPage) return null; if (monitors.length === 0) { return ( {t("pages.statusPages.details.empty.title")} {isAdmin && ( {t("pages.statusPages.details.empty.addMonitor")} )} ); } const ThemedRenderer = THEMED_RENDERERS[resolveStatusPageTheme(statusPage.theme)]; const themedRenderer = ( ); // Public route: render directly on the viewport, themed background covers everything. if (isPublic) { return ( {themedRenderer} ); } // Admin preview: wrap in a mock browser frame inside the admin shell. const publicUrl = `${window.location.origin}/status/public/${statusPage.url}`; return ( {themedRenderer} ); }; export default StatusPageView;