import Box from "@mui/material/Box"; import { useTheme } from "@mui/material/styles"; import type { ICheck } from "@/types/check"; import { getResponseColor } from "@/utils/DataUtils"; import { HeatmapResponseTimeTooltip } from "./HeatmapResponseTimeTooltip"; import type { SxProps } from "@mui/material/styles"; import type { ResponsiveStyleValue } from "@mui/system"; interface HeatmapResponseTimeProps { checks: ICheck[]; gap?: ResponsiveStyleValue; availabilityCellSx?: SxProps; responseCellSx?: SxProps; } export const HeatmapResponseTime = ({ checks, gap, availabilityCellSx, responseCellSx, }: HeatmapResponseTimeProps) => { const theme = useTheme(); if (!gap) { gap = theme.spacing(0.5); } if (!checks || checks.length === 0) return null; let data = Array(); if (!checks || checks.length === 0) { checks = []; } if (checks.length !== 25) { const placeholders = Array(25 - checks.length).fill({ status: "placeholder", }); data = [...checks, ...placeholders]; } else { data = checks; } return ( {data.map((check, index) => { const statusBg = check.status === "placeholder" ? theme.palette.action.hover : check.status === "up" ? theme.palette.success.light : theme.palette.error.light; const respBg = check.status === "placeholder" ? theme.palette.action.hover : getResponseColor(check.responseTime, { start: theme.palette.success.main, mid: theme.palette.warning.main, end: theme.palette.error.main, }); const statusBorder = check.status === "placeholder" ? theme.palette.divider : check.status === "up" ? theme.palette.success.main : theme.palette.error.main; return ( ); })} ); };