260202_04_ENH: Total 하위 페이지들에 useMemo 적용 및 LifeStyle 샘플 데이터 전체 값 조정
This commit is contained in:
@@ -1,33 +1,40 @@
|
||||
'use client'
|
||||
"use client";
|
||||
|
||||
import {PRODUCT_KEYS, PRODUCTS, AXIS_HIDE_STYLE, GRID_X_NOT_PADDING} from "@/const/lgConst";
|
||||
import { useMemo } from "react";
|
||||
import { PRODUCT_KEYS, PRODUCTS, AXIS_HIDE_STYLE, GRID_X_NOT_PADDING } from "@/const/lgConst";
|
||||
import {
|
||||
ChartData,
|
||||
signStyleGapRow, TopChartTable,
|
||||
TopChartTableRow, VerticalBar
|
||||
type ChartData,
|
||||
signStyleGapRow,
|
||||
TopChartTable,
|
||||
type TopChartTableRow,
|
||||
VerticalBar,
|
||||
} from "@/components/lge-dashboard";
|
||||
import {apiTrendBuy} from "@/config/sample.data";
|
||||
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
|
||||
import {formatRowLabel} from "@/lib/lg-dashboard";
|
||||
import { apiTrendBuy } from "@/config/sample.data";
|
||||
import { useLayoutFilter } from "@/components/layout/LayoutFilterContext";
|
||||
import { formatRowLabel } from "@/lib/lg-dashboard";
|
||||
|
||||
const PurchasePage = () => {
|
||||
const { isTotal, filterValue } = useLayoutFilter();
|
||||
console.log(filterValue);
|
||||
|
||||
const purchaseTableRows: TopChartTableRow[] = apiTrendBuy.map((row, i) => ({
|
||||
label: formatRowLabel(row.rowLabel),
|
||||
values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null),
|
||||
}));
|
||||
const purchaseTableRows = useMemo<TopChartTableRow[]>(() => {
|
||||
return apiTrendBuy.map((row) => ({
|
||||
label: formatRowLabel(row.rowLabel),
|
||||
values: PRODUCT_KEYS.map((k) => (row as any)[k] ?? null),
|
||||
}));
|
||||
}, []);
|
||||
|
||||
const purchaseChartData: ChartData = {
|
||||
categories: [...PRODUCTS], // 한글 라벨(세탁기/냉장고/...)
|
||||
series: apiTrendBuy
|
||||
.filter((r) => r.rowLabel.endsWith("년")) // 24년/25년/26년만 차트에 사용
|
||||
.map((r) => ({
|
||||
name: r.rowLabel, // legend: 24년/25년/26년
|
||||
data: PRODUCT_KEYS.map((k) => (r as any)[k] ?? null),
|
||||
})),
|
||||
}
|
||||
const purchaseChartData = useMemo<ChartData>(() => {
|
||||
return {
|
||||
categories: [...PRODUCTS],
|
||||
series: apiTrendBuy
|
||||
.filter((r) => r.rowLabel.endsWith("년"))
|
||||
.map((r) => ({
|
||||
name: r.rowLabel,
|
||||
data: PRODUCT_KEYS.map((k) => (r as any)[k] ?? null),
|
||||
})),
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -50,6 +57,6 @@ const PurchasePage = () => {
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default PurchasePage;
|
||||
Reference in New Issue
Block a user