260331_08_ENH: 누락 내용 주석으로 추가(고객사 요청 시 풀것)

This commit is contained in:
2026-03-31 17:57:11 +09:00
parent 59943b2e45
commit f6b5b21cb2
2 changed files with 59 additions and 6 deletions

View File

@@ -6,7 +6,7 @@ import {CategoryTargetData} from "@/types/filter.types";
import {BannerRow, CategoryResolvedField, StatisticsRequest} from "@/types/lg.types";
import {useDebouncedValue} from "@/hooks/useDebouncedValue";
import {CategoryFilterValue} from "@/components/layout/CategoryFilter";
import {buildCategoryFilter, buildPageModeConfig} from "@/lib/lg-dashboard";
import {buildCategoryFilter, buildGapRow, buildPageModeConfig} from "@/lib/lg-dashboard";
import {BANNER_GROUP_KEY} from "@/const/lg-banner.const";
import {API_DECIMAL_POINT, USE_CACHE} from "@/const/lg-common.const";
import Profile from "./category-page/Profile";
@@ -18,6 +18,7 @@ export type CategoryPageProps = {
fields: CategoryResolvedField[];
variableIdMap: Record<string, string>;
dataMap:Record<string, BannerRow[]> | undefined;
fillGreaterThan5?: boolean;
}
const PAGE_COMPONENTS: Partial<Record<CategoryTargetData, React.ComponentType<CategoryPageProps>>> = {
@@ -50,10 +51,60 @@ const CategoryPage = () => {
const { data } = useBannerStatisticsQuery(req);
const dataMap = data?.statisticsDataMap;
const target = debouncedFilterValue.target;
const Comp = PAGE_COMPONENTS[target.value]
//고객사 요청 시에 아래 주석 풀고 false 대신 넘기기
const fillGreaterThan5 = false//target.value === CategoryTargetData.BRAND && !!dataMap;
//고객사 요청 시에 아래 주석 풀고 dataMap대신 processedDataMap로 넘기기
/*
const processedDataMap = useMemo(() => {
if (!dataMap || target.value !== CategoryTargetData.BRAND) {
return dataMap;
}
const nextMap: Record<string, BannerRow[]> = { ...dataMap };
fields.forEach((f) => {
const rows = dataMap[f.requestKeyResolved];
if (!rows?.length) return;
const years = Array.from(new Set(rows.map((row) => Number(row.year))))
.filter((year) => Number.isFinite(year))
.sort((a, b) => b - a)
.slice(0, 2);
if (years.length < 2) {
nextMap[f.requestKeyResolved] = rows;
return;
}
const [currentYear, prevYear] = years;
const gapRow = buildGapRow(rows, prevYear, currentYear, "LG");
if (!gapRow) {
nextMap[f.requestKeyResolved] = rows;
return;
}
const nextRows: BannerRow[] = [];
rows.forEach((row) => {
nextRows.push(row);
if (Number(row.year) === currentYear && row.rowLabel === "LG") {
nextRows.push(gapRow);
}
});
nextMap[f.requestKeyResolved] = nextRows;
});
return nextMap;
}, [dataMap, fields, target.value]);
*/
const Comp = PAGE_COMPONENTS[target.value];
if(isTotal) return null;
return Comp ? <Comp fields={fields} variableIdMap={variableIdMap} dataMap={dataMap} /> : null;
return Comp ? <Comp fields={fields} variableIdMap={variableIdMap} dataMap={dataMap} fillGreaterThan5={fillGreaterThan5} /> : null;
}
export default CategoryPage;

View File

@@ -13,9 +13,10 @@ import {CategoryByData} from "@/components/lge-dashboard";
import {wrapSampleRow} from "@/lib/lg-dashboard";
const CategoryDetail = ({
fields,
dataMap
}:CategoryPageProps) => {
fields,
dataMap,
fillGreaterThan5
}:CategoryPageProps) => {
const {filterValue, registerExcelExporter} = useLayoutFilter();
const debouncedFilterValue = useDebouncedValue<CategoryFilterValue>(filterValue as CategoryFilterValue, 500);
@@ -87,6 +88,7 @@ const CategoryDetail = ({
allTableData={tableData.data}
chartHeight={tableData.chartHeight}
chartWidth={tableData.chartWidth}
fillGreaterThan5={fillGreaterThan5}
/>
))}
</div>