Files
Checkmate/client/src/Pages/PageSpeed/Monitors/index.jsx
T

98 lines
2.7 KiB
React
Raw Normal View History

2025-01-28 11:04:11 -08:00
// Components
import { useState } from "react";
2025-09-27 14:54:55 -07:00
import Breadcrumbs from "@/Components/v1/Breadcrumbs/index.jsx";
2025-09-05 15:53:22 -04:00
import { Stack } from "@mui/material";
2025-09-27 14:54:55 -07:00
import CreateMonitorHeader from "@/Components/v1/MonitorCreateHeader/index.jsx";
import MonitorCountHeader from "@/Components/v1/MonitorCountHeader/index.jsx";
2025-09-25 10:11:41 -07:00
import MonitorGrid from "./Components/MonitorGrid/index.jsx";
2025-09-27 14:54:55 -07:00
import PageStateWrapper from "@/Components/v1/PageStateWrapper/index.jsx";
import FallbackPageSpeedWarning from "@/Components/v1/Fallback/FallbackPageSpeedWarning.jsx";
2025-01-28 11:04:11 -08:00
// Utils
import { useTheme } from "@emotion/react";
2026-01-12 23:57:39 +00:00
import { useIsAdmin } from "@/Hooks/useIsAdmin.js";
import {
useFetchMonitorsByTeamId,
useFetchMonitorsWithChecks,
} from "@/Hooks/monitorHooks.js";
import { useFetchSettings } from "@/Hooks/settingsHooks.js";
2025-01-28 11:04:11 -08:00
// Constants
const BREADCRUMBS = [{ name: `pagespeed`, path: "/pagespeed" }];
2025-06-12 12:44:46 +08:00
const TYPES = ["pagespeed"];
2025-01-28 11:06:24 -08:00
const PageSpeed = () => {
2025-01-28 11:04:11 -08:00
const theme = useTheme();
const isAdmin = useIsAdmin();
2026-01-12 23:57:39 +00:00
// const [monitors, monitorsSummary, isLoading, networkError] = useFetchMonitorsByTeamId({
// limit: 10,
// types: TYPES,
// page: null,
// rowsPerPage: null,
// filter: null,
// field: null,
// order: null,
// });
const [
monitorsWithChecks,
monitorsWithChecksCount,
monitorsWithChecksIsLoading,
monitorsWithChecksNetworkError,
] = useFetchMonitorsWithChecks({
2025-06-12 12:44:46 +08:00
types: TYPES,
2026-01-12 23:57:39 +00:00
limit: 10,
2025-06-12 12:44:46 +08:00
page: null,
rowsPerPage: null,
filter: null,
field: null,
order: null,
2026-01-12 23:57:39 +00:00
monitorUpdateTrigger: null,
2025-01-28 11:04:11 -08:00
});
const [settingsData, setSettingsData] = useState(undefined);
const [isSettingsLoading, settingsError] = useFetchSettings({
setSettingsData,
setIsApiKeySet: () => {},
setIsEmailPasswordSet: () => {},
});
2025-01-28 11:04:11 -08:00
return (
2025-09-05 15:53:22 -04:00
<>
<PageStateWrapper
2026-01-12 23:57:39 +00:00
networkError={monitorsWithChecksNetworkError}
isLoading={monitorsWithChecksIsLoading}
items={monitorsWithChecks}
2025-09-05 15:53:22 -04:00
type="pageSpeed"
fallbackLink="/pagespeed/create"
fallbackChildren={
isAdmin &&
settingsData &&
!settingsData.pagespeedApiKey && (
<FallbackPageSpeedWarning settingsData={settingsData} />
)
}
>
<Stack gap={theme.spacing(10)}>
<Breadcrumbs list={BREADCRUMBS} />
<CreateMonitorHeader
isAdmin={isAdmin}
2026-01-12 23:57:39 +00:00
isLoading={monitorsWithChecksIsLoading}
2025-09-05 15:53:22 -04:00
path="/pagespeed/create"
/>
<MonitorCountHeader
2026-01-12 23:57:39 +00:00
isLoading={monitorsWithChecksIsLoading}
monitorCount={monitorsWithChecksCount}
2025-09-05 15:53:22 -04:00
sx={{ mb: theme.spacing(8) }}
/>
<MonitorGrid
size={6}
2026-01-12 23:57:39 +00:00
shouldRender={!monitorsWithChecksIsLoading}
monitors={monitorsWithChecks}
2025-09-05 15:53:22 -04:00
/>
</Stack>
</PageStateWrapper>
</>
2025-01-28 11:04:11 -08:00
);
};
2025-01-28 11:06:24 -08:00
export default PageSpeed;