Files
Checkmate/client/src/Pages/Checks/index.tsx
T

53 lines
1.5 KiB
TypeScript
Raw Normal View History

2026-01-27 22:24:16 +00:00
import Stack from "@mui/material/Stack";
import { BasePage, TotalChecksBox, DownChecksBox } from "@/Components/v2/design-elements";
2026-01-27 21:57:09 +00:00
import { useTheme } from "@mui/material";
import { useTranslation } from "react-i18next";
import { useState, useEffect, useMemo } from "react";
import { useParams } from "react-router-dom";
import { useGet } from "@/Hooks/UseApi";
2026-01-27 22:24:16 +00:00
import type { Monitor } from "@/Types/Monitor";
import type { ChecksSummary } from "@/Types/Check";
2026-01-27 21:57:09 +00:00
const Checks = () => {
const { t } = useTranslation();
const theme = useTheme();
const { monitorId } = useParams<{ monitorId?: string }>();
// Local state
const [selectedMonitor, setSelectedMonitor] = useState<string>("0");
const [filter, setFilter] = useState<boolean | undefined>(undefined);
const [dateRange, setDateRange] = useState<string>("hour");
// Data fetching with SWR
const monitorsUrl = "/monitors/team";
const summaryUrl = `/checks/team/summary?dateRange=${dateRange}`;
const {
data: monitorsResponse,
isLoading: isLoadingMonitors,
error: monitorsError,
} = useGet<Monitor[]>(monitorsUrl);
const {
data: summaryResponse,
isLoading: isLoadingSummary,
error: summaryError,
} = useGet<ChecksSummary>(summaryUrl);
console.log(monitorsResponse, summaryResponse);
return (
<BasePage>
2026-01-27 22:24:16 +00:00
<Stack
direction={{ xs: "column", md: "row" }}
gap={4}
>
<TotalChecksBox n={summaryResponse?.totalChecks || 0} />
<DownChecksBox n={summaryResponse?.downChecks || 0} />
</Stack>
2026-01-27 21:57:09 +00:00
</BasePage>
);
};
export default Checks;