import Grid from "@mui/material/Grid"; import { HistogramInfrastructure } from "@/components/monitors"; import type { IInfraCheck } from "@/types/check"; import { useMemo } from "react"; import { useTheme } from "@mui/material/styles"; import useMediaQuery from "@mui/material/useMediaQuery"; const getChartConfigs = (theme: any, checks: IInfraCheck[]) => { return [ { type: "memory", dataKeys: ["memory.usage_percent"], strokeColor: theme.palette.primary.main, gradientStartColor: theme.palette.primary.main, yDomain: [0, 1], idx: null, }, { type: "cpu", dataKeys: ["cpu.used_percent"], strokeColor: theme.palette.success.main, gradientStartColor: theme.palette.success.main, yDomain: [0, 1], idx: null, }, { type: "temp", dataKeys: ["avg_temp"], strokeColor: theme.palette.error.main, gradientStartColor: theme.palette.error.main, yDomain: [0, 150], idx: null, }, ...(checks[0]?.disk?.map((_, idx) => ({ type: "disk", dataKeys: [`disk[${idx}].usage_percent`], strokeColor: theme.palette.warning.main, gradientStartColor: theme.palette.warning.main, yDomain: [0, 1], idx, })) || []), ]; }; export const InfraDetailsGraphs = ({ checks, range, }: { checks: IInfraCheck[]; range: string; }) => { const theme = useTheme(); const isSmall = useMediaQuery(theme.breakpoints.down("md")); const chartConfigs = useMemo( () => getChartConfigs(theme, checks), [theme, checks] ); return ( {chartConfigs.map((config) => { return ( ); })} ); };