fix: changes fixing type errors and adding colorFn comment

This commit is contained in:
mannilakash committed 2026-03-30 08:15:43 -04:00
1 parent 6cea199e4f
commit 41fa2717a9
2 files changed
+10 -8

No files matched your search

@@ -3,7 +3,7 @@ import Stack from "@mui/material/Stack";
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import { useTheme } from "@mui/material/styles";
import { useTheme, type Theme } from "@mui/material/styles";
import { useMemo, useState, useEffect } from "react";
import { getInfraGaugeColor } from "@/Utils/MonitorUtils";
@@ -17,6 +17,9 @@ export const Gauge = ({
strokeWidth = 15,
precision = 1,
unit = "%",
// colorFn lets callers override the default color logic.
// The Gauge was originally designed for metrics where higher values are worse (e.g., CPU usage).
// PageSpeed scores are the opposite—higher is better—so a custom colorFn can be used to invert the behavior.
colorFn,
}: {
isLoading?: boolean;
@@ -25,7 +28,7 @@ export const Gauge = ({
strokeWidth?: number;
precision?: number;
unit?: string;
colorFn?: (val: number, theme: any) => string;
colorFn?: (val: number, theme: Theme) => string;
}) => {
const theme = useTheme();
const progressWithinRange = Math.max(MINIMUM_VALUE, Math.min(progress, MAXIMUM_VALUE));
@@ -27,14 +27,12 @@ interface MonitorsListProps {
}
const getMonitorBadgeStyles = (monitorType: string, theme: Theme) => {
const monitorColors = {
const monitorColors: Record<string, string> = {
hardware: theme.palette.info.light,
pagespeed: theme.palette.warning.light,
};
const bg =
monitorColors[monitorType as keyof typeof monitorColors] ||
theme.palette.success.light;
const bg = monitorColors[monitorType] || theme.palette.success.light;
return {
backgroundColor: bg,
color: theme.palette.background.paper,
@@ -113,8 +111,9 @@ const MonitorContent = ({
}
if (monitor.type === "pagespeed") {
if (statusPage.showPageSpeed === false) return null;
return <PageSpeedMetrics monitor={monitor} />;
return statusPage.showPageSpeed === false ? null : (
<PageSpeedMetrics monitor={monitor} />
);
}
if (statusPage.showCharts === false) return null;