import Stack from "@mui/material/Stack"; import Typography from "@mui/material/Typography"; import { useTheme } from "@mui/material/styles"; import { Link as RouterLink } from "react-router-dom"; import { useTranslation } from "react-i18next"; import { Dot } from "@/Components/design-elements"; import { LAYOUT } from "@/Utils/Theme/constants"; import { typographyLevels } from "@/Utils/Theme/Palette"; import { getStatusColor } from "@/Utils/MonitorUtils"; import { DashboardCard, CardMessage } from "../DashboardCard"; import { useMonitors } from "../../useDashboardData"; import type { MonitorStatus, MonitorsSummary } from "@/Types/Monitor"; // Wide enough for a three-digit count beside its label before the tiles wrap. const TILE_MIN_WIDTH = 96; // Every state the summary reports, in the order they read: healthy first, then // what is wrong, then what is not being checked. All six are listed so the // tiles always sum to totalMonitors — omitting one leaves an unexplained gap. const COUNTS: { key: string; status: MonitorStatus; field: keyof MonitorsSummary }[] = [ { key: "up", status: "up", field: "upMonitors" }, { key: "down", status: "down", field: "downMonitors" }, { key: "breached", status: "breached", field: "breachedMonitors" }, { key: "maintenance", status: "maintenance", field: "maintenanceMonitors" }, { key: "paused", status: "paused", field: "pausedMonitors" }, { key: "initializing", status: "initializing", field: "initializingMonitors" }, ]; export const MonitorStatusCard = () => { const theme = useTheme(); const { t } = useTranslation(); const { data, isLoading, isValidating, error } = useMonitors(); const summary = data?.summary ?? null; return ( {!summary || summary.totalMonitors === 0 ? ( ) : ( {COUNTS.map(({ key, status, field }) => ( {t(`pages.common.monitors.status.${key}`)} {summary[field]} ))} )} ); };