fix(client): resolve TS2769 error in ThemedHeatmap and ThemedHistogram

This commit is contained in:
nikhil2004 committed 2026-09-22 03:31:14 +05:30
1 parent 97e23e4b3a
commit 2c896a5506
3 files changed
+28 -20

No files matched your search

@@ -2,6 +2,7 @@ import Tooltip from "@mui/material/Tooltip";
import Box from "@mui/material/Box"; import Box from "@mui/material/Box";
import type { SxProps, Theme } from "@mui/material/styles"; import type { SxProps, Theme } from "@mui/material/styles";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { mergeSx } from "@/Utils/mergeSx";
import type { import type {
ChartCell, ChartCell,
HeatCellKind, HeatCellKind,
@@ -19,10 +20,10 @@ export const ThemedHeatmap = ({ cells, containerSx, cellSx, onCellClick }: Props
return ( return (
<Box <Box
sx={[ sx={mergeSx(
...(Array.isArray(containerSx) ? containerSx : [containerSx]), containerSx,
{ gridTemplateColumns: `repeat(${cells.length}, 1fr)` }, { gridTemplateColumns: `repeat(${cells.length}, 1fr)` }
]} )}
role="img" role="img"
aria-label={t("pages.statusPages.monitorsList.chart.heatmapAria")} aria-label={t("pages.statusPages.monitorsList.chart.heatmapAria")}
> >
@@ -31,10 +32,10 @@ export const ThemedHeatmap = ({ cells, containerSx, cellSx, onCellClick }: Props
return ( return (
<Box <Box
key={cell.key} key={cell.key}
sx={[ sx={mergeSx(
cellSx("empty"), cellSx("empty"),
!!cell.date && !!onCellClick && { cursor: "pointer" }, !!cell.date && !!onCellClick ? { cursor: "pointer" } : undefined
]} )}
onClick={() => { onClick={() => {
if (cell.date && onCellClick) { if (cell.date && onCellClick) {
onCellClick(cell.date); onCellClick(cell.date);
@@ -51,10 +52,10 @@ export const ThemedHeatmap = ({ cells, containerSx, cellSx, onCellClick }: Props
placement="top" placement="top"
> >
<Box <Box
sx={[ sx={mergeSx(
cellSx(cell.heatKind, cell.severity), cellSx(cell.heatKind, cell.severity),
!!cell.date && !!onCellClick && { cursor: "pointer" }, !!cell.date && !!onCellClick ? { cursor: "pointer" } : undefined
]} )}
aria-label={cell.ariaLabel} aria-label={cell.ariaLabel}
onClick={() => { onClick={() => {
if (cell.date && onCellClick) { if (cell.date && onCellClick) {
@@ -5,6 +5,7 @@ import Stack from "@mui/material/Stack";
import type { SxProps, Theme } from "@mui/material/styles"; import type { SxProps, Theme } from "@mui/material/styles";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { formatMs } from "@/Utils/TimeUtils"; import { formatMs } from "@/Utils/TimeUtils";
import { mergeSx } from "@/Utils/mergeSx";
import type { import type {
BarKind, BarKind,
ChartCell, ChartCell,
@@ -41,20 +42,20 @@ export const ThemedHistogram = ({
return ( return (
<Stack gap={statsGap}> <Stack gap={statsGap}>
<Box <Box
sx={[ sx={mergeSx(
...(Array.isArray(containerSx) ? containerSx : [containerSx]), containerSx,
{ gridTemplateColumns: `repeat(${cells.length}, 1fr)` }, { gridTemplateColumns: `repeat(${cells.length}, 1fr)` }
]} )}
> >
{cells.map((cell) => { {cells.map((cell) => {
if (cell.barKind === "empty") { if (cell.barKind === "empty") {
return ( return (
<Box <Box
key={cell.key} key={cell.key}
sx={[ sx={mergeSx(
barSx("empty", cell.heightPct), barSx("empty", cell.heightPct),
!!cell.date && !!onCellClick && { cursor: "pointer" }, !!cell.date && !!onCellClick ? { cursor: "pointer" } : undefined
]} )}
onClick={() => { onClick={() => {
if (cell.date && onCellClick) { if (cell.date && onCellClick) {
onCellClick(cell.date); onCellClick(cell.date);
@@ -71,10 +72,10 @@ export const ThemedHistogram = ({
placement="top" placement="top"
> >
<Box <Box
sx={[ sx={mergeSx(
barSx(cell.barKind, cell.heightPct, cell.severity), barSx(cell.barKind, cell.heightPct, cell.severity),
!!cell.date && !!onCellClick && { cursor: "pointer" }, !!cell.date && !!onCellClick ? { cursor: "pointer" } : undefined
]} )}
aria-label={cell.ariaLabel} aria-label={cell.ariaLabel}
onClick={() => { onClick={() => {
if (cell.date && onCellClick) { if (cell.date && onCellClick) {
+6
View File
@@ -0,0 +1,6 @@
import type { SxProps, Theme } from "@mui/material/styles";
export const mergeSx = (...styles: Array<SxProps<Theme> | false | null | undefined>): SxProps<Theme> =>
styles
.flatMap((style) => (Array.isArray(style) ? style : [style]))
.filter(Boolean) as SxProps<Theme>;