260129_01_ENH: 카테고리 파트 layout 및 route 구조 변경

This commit is contained in:
2026-01-29 13:42:42 +09:00
parent d48decab52
commit 4b40c43962
34 changed files with 508 additions and 309 deletions

View File

@@ -1,20 +1,21 @@
'use client'
import {
GaugeCardTable, GaugeColumn,
GroupedOverlayBar, GroupedOverlayBarData, LifeStageRow,
GroupedOverlayBar, GroupedOverlayBarData,
signStyleGapRow, TopChartTable, TopChartTableRow
} from "@/components/lge-dashboard";
import {PRODUCT_KEYS, PRODUCTS, YEARS} from "@/const/lgConst";
import {useMemo} from "react";
import {
apiLifeStageByProduct,
apiLifeStageByProductForGauge,
apiOwnShareOfTotalPenetration,
apiTrendCategories
} from "@/config/sample.data";
import LifeStageDiv from "@/components/lge-dashboard/sub-page/LifeStageDiv";
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
const LGPenetrationPage = () => {
const { totalValue } = useLayoutFilter();
console.log(totalValue);
const displayRowLabel = (i:number, rowLabel: string) => {
if (rowLabel === "gap") return "전년 대비 GAP(%)";
@@ -57,52 +58,7 @@ const LGPenetrationPage = () => {
focus: focus,
}
const norm = (s: string) => s.replace(/\s+/g, "").toLowerCase();
const asNum = (v: unknown): number | null => typeof v === "number" && Number.isFinite(v) ? v : null;
const LIFE_STAGE_COLUMNS: GaugeColumn<LifeStageRow>[] = [
{ key: "item", header: "", rowHead: true, renderLabel: (r) => r.item },
{ key: "total", header: "전체", max: 100, align: "left", cellType:"number"},
{ key: "single", header: "미혼", max: 100 , align: "left"},
{ key: "noKids", header: "무자녀", group: "기혼", max: 100 , align: "left"},
{ key: "preschoolKids", header: "미취학", group: "기혼", max: 100 , align: "left"},
{ key: "schoolKids", header: "취학자녀", group: "기혼", max: 100 , align: "left"},
{ key: "adultKids", header: "성인자녀", group: "기혼", max: 100 , align: "left"},
{ key: "independentSenior", header: "독립\n시니어", max: 100 , align: "left"},
];
const LIFE_STAGE_GROUPS = [
{ title: "필수가전 군", items: ["냉장고", "세탁기", "에어컨", "TV", "청소기", "김치 냉장고"] },
{ title: "케어가전 군", items: ["공기 청정기", "가습기", "제습기"] },
{ title: "Must & Best", items: ["건조기", "식기 세척기", "의류 관리기"] },
{ title: "신가전 군", items: ["로봇 청소기"] },
] as const;
const lifeStageRowsByGroup = useMemo(() => {
const pick = (label: string) => apiLifeStageByProduct.find((r) => norm(r.rowLabel) === norm(label));
return LIFE_STAGE_GROUPS.map((g) => {
const rows: LifeStageRow[] = g.items.map((label) => {
const r = pick(label);
return {
item: label,
total: asNum((r as any)?.total), // 서버에 all이 없으면 null로 남음
single: asNum((r as any)?.single),
noKids: asNum((r as any)?.noKids),
preschoolKids: asNum((r as any)?.preschoolKids),
schoolKids: asNum((r as any)?.schoolKids),
adultKids: asNum((r as any)?.adultKids),
independentSenior: asNum((r as any)?.independentSenior),
};
});
return { title: g.title, rows };
});
}, []);
return (
<div>
@@ -121,33 +77,7 @@ const LGPenetrationPage = () => {
signStyle={signStyleGapRow}
/>
<div className="mt-6">
<div className="flex justify-end gap-6 text-xs text-muted-foreground mb-2">
<div className="flex items-center gap-2">
<span className="inline-block h-4 w-8 border bg-gray-200 border-gray-300"/>
<span>제품 보유율</span>
</div>
<div className="flex items-center gap-2">
<span
className="inline-block h-4 w-8 border border-gray-300"
style={{ backgroundColor: "hsl(var(--lg-pink-300) / 0.4)" }}
/>
<span>시장 기회공간</span>
</div>
</div>
<div className="grid grid-cols-2 gap-4">
{lifeStageRowsByGroup.map((g) => (
<GaugeCardTable
key={g.title}
title={g.title}
columns={LIFE_STAGE_COLUMNS}
rows={g.rows}
/>
))}
</div>
</div>
<LifeStageDiv/>
</div>
);