260202_03_ENH: 페이지 깜빡임 최소화 및 카테고리에서 전체로 이동 시 페이지 렌더링 2회 되는 부분 수정

This commit is contained in:
2026-02-02 15:05:11 +09:00
parent 0950679874
commit 84560cef2d
9 changed files with 90 additions and 71 deletions

View File

@@ -1,6 +1,7 @@
import {BannerGroupKey, ServerBannerRow} from "@/types/lg";
import {ChartData} from "@/components/lge-dashboard";
import {BANNER_GROUP} from "@/const/lgConst";
import {formatNumber} from "@/lib/utils";
export const isSampleRow = (raw: string) => raw.replace(/\s+/g, "") === "사례수";
@@ -45,6 +46,35 @@ export function formatRowLabel(
return t;
}
export const wrapSampleRow = <T extends Record<string, unknown> & { rowLabel: string }>(
rows: T[]
): T[] => {
return rows.map((r) => {
if (!isSampleRow(r.rowLabel)) return r;
const out: any = { ...r };
Object.entries(r).forEach(([k, v]) => {
if (k == "year" || v == null) return;
if (typeof v === "number") {
out[k] = `(${formatNumber(v)})`;
return;
}
if (typeof v === "string") {
// 이미 괄호면 그대로
out[k] = v.startsWith("(") && v.endsWith(")") ? v : `(${v})`;
return;
}
out[k] = `(${String(v)})`;
});
return out as T;
});
};
/**
* 연도 배열로부터 연도 -> 인덱스 맵을 생성합니다.
* @param years - 연도 배열 (예: [2024, 2025, 2026])