diff --git a/src/app/(pages)/(main)/safety-inspection/sub/SafetyInspectionTotal.tsx b/src/app/(pages)/(main)/safety-inspection/sub/SafetyInspectionTotal.tsx index 63c18c8..f7a88c0 100644 --- a/src/app/(pages)/(main)/safety-inspection/sub/SafetyInspectionTotal.tsx +++ b/src/app/(pages)/(main)/safety-inspection/sub/SafetyInspectionTotal.tsx @@ -152,7 +152,7 @@ const SafetyInspectionTotal = () => { ) ).sort((a, b) => a - b); - const latestWave = waves[waves.length - 1]; + const latestWave = waves.at(-1); const selectedWaves = latestWave == null ? [] : [latestWave - 1, latestWave]; const categories = DIV_COLUMNS.map((div) => div.label); @@ -171,19 +171,28 @@ const SafetyInspectionTotal = () => { label: getWaveLabel(wave), values: DIV_COLUMNS.map((div) => getMetricValue(data, div.key, wave, metric.key)), })), - ].map((row, rowIndex) => ({ - ...row, - preAppendCells: getPreAppendCells(metric, metricIndex, rowIndex, selectedWaves.length + 1), - labelClassName: - metric.key === "csi" - ? cn("bg-red-100 text-center", row.label !== GAP_WORDING && "font-bold") - : metric.group === "indirect" - ? cn("bg-green-200 text-center", row.label !== GAP_WORDING && "font-bold") - : metric.group === "direct" - ? cn("bg-red-50 text-center", row.label !== GAP_WORDING && "font-bold") - : cn("text-center", row.label !== GAP_WORDING && "font-bold"), - labelWidth: 90, - })) + ].map((row, rowIndex) => { + let labelColorClassName: string | undefined; + + if (metric.key === "csi") { + labelColorClassName = "bg-red-100"; + } else if (metric.group === "indirect") { + labelColorClassName = "bg-green-200"; + } else if (metric.group === "direct") { + labelColorClassName = "bg-red-50"; + } + + return { + ...row, + preAppendCells: getPreAppendCells(metric, metricIndex, rowIndex, selectedWaves.length + 1), + labelClassName: cn( + labelColorClassName, + "text-center", + row.label !== GAP_WORDING && "font-bold" + ), + labelWidth: 90, + }; + }) ); const verticalChartData: ChartData = {