260518_02_ENH: 전체현황, 안전점검에 지역본부 평균 대비 row 추가

This commit is contained in:
2026-05-18 15:35:08 +09:00
parent eddf9da03e
commit 9f0cc7d7e3
14 changed files with 76 additions and 44 deletions

View File

@@ -9,7 +9,7 @@ import { useCsiDataQuery } from "@/query/statistics";
import type { DashboardMetricConfig, DashboardMetricGroup } from "@/types/kfpa";
import VerticalBar from "@/components/chart/VerticalBar";
import type { DataColumn } from "@/components/table/types";
import { GAP_WORDING } from "@/const/kfpa.const";
import {
CUSTOMER_SATISFACTION_GAP_SIGN_STYLE,
DASHBOARD_METRIC_GROUP_LABEL_MAP,
@@ -17,14 +17,15 @@ import {
REGION_KEY_MAP,
getDashboardMetricConfigs,
getDashboardTotalColumnEntries,
getDashboardTotalTableLayout,
} from "@/config/kfpaConfig";
import type { DashboardTotalTableLayout } from "@/config/kfpaConfig";
getDashboardTotalTableLayout, GAP_WORDING, AVERAGE_GAP_WORDING, DIV_KEYS,
} from "@/config/kfpa.config";
import type { DashboardTotalTableLayout } from "@/config/kfpa.config";
import { useLayoutFilter } from "@/components/layout/LayoutCategoryContext";
import {
getAverageGapValue,
getCsiDataByWave,
getCsiMetricGapValue,
getCsiMetricValue,
getCsiMetricValue, getSummaryDataKey,
getWaveLabel,
} from "@/lib/kfpa-util";
@@ -95,7 +96,9 @@ const CustomerSatisfactionTotal = () => {
[categoryKey]
);
const { categoryColumns, categories, rows, verticalChartData } = useMemo(() => {
const addAverageGapRow = useMemo(() => categoryKey === "2601009_A", [categoryKey]);
const { categoryColumns, categories, rows, chartData } = useMemo(() => {
const waves = Array.from(
new Set(
Object.values(data ?? {})
@@ -116,7 +119,7 @@ const CustomerSatisfactionTotal = () => {
const categories = divisionColumns.map((div) => div.label);
const rows: TopChartTableRow[] =
selectedWaves.length === 0
selectedWaves.length === 0 || latestWave == undefined
? []
: metrics.flatMap((metric, metricIndex) =>
[
@@ -130,6 +133,13 @@ const CustomerSatisfactionTotal = () => {
label: getWaveLabel(wave),
values: divisionColumns.map((div) => getCsiMetricValue(data, div.key, wave, metric.key)),
})),
...(addAverageGapRow && metric.group === "csi"
? [{
label: AVERAGE_GAP_WORDING,
values: divisionColumns.map((div) => getAverageGapValue(data, DIV_KEYS[0], div.key, latestWave)),
}]
: []
),
].map((row, rowIndex) => ({
...row,
preAppendCells: getPreAppendCells(
@@ -137,7 +147,7 @@ const CustomerSatisfactionTotal = () => {
metric,
metricIndex,
rowIndex,
selectedWaves.length + 1,
selectedWaves.length + (addAverageGapRow && metric.group === "csi"? 2 : 1),
tableLayout
),
labelClassName: cn(`bg-${metric.group}`, "text-center", row.label !== GAP_WORDING && "font-bold"),
@@ -145,7 +155,7 @@ const CustomerSatisfactionTotal = () => {
}))
);
const verticalChartData: ChartData = {
const chartData: ChartData = {
categories,
series: selectedWaves.map((wave) => ({
name: getWaveLabel(wave),
@@ -157,7 +167,7 @@ const CustomerSatisfactionTotal = () => {
categoryColumns,
categories,
rows,
verticalChartData,
chartData,
};
}, [data, divisionColumns, metrics, tableLayout]);
@@ -197,7 +207,7 @@ const CustomerSatisfactionTotal = () => {
rows={rows}
sectionRows={[
{
afterRowIndex: 2,
afterRowIndex: addAverageGapRow? 3 : 2,
content: "고객만족지수 세부 항목",
className: "bg-gray-400 text-center font-bold",
bodyClassName: "bg-gray-400 text-center",
@@ -209,14 +219,14 @@ const CustomerSatisfactionTotal = () => {
chartHeight={200}
chart={
<VerticalBar
data={verticalChartData}
data={chartData}
height="100%"
paletteVarNames={["--chart-5", "--chart-7"]}
valueFormatter={(value) => value.toFixed(2)}
barMaxWidth={30}
showFocusLabel="all"
labelOptions={{ position: "top", distance: 4 }}
grid={{ left: 0, right: 0, top: 40, bottom: 5 }}
grid={{ left: 0, right: 0, top: 20, bottom: 5 }}
xAxis={{
type: "category",
data: categories,