diff --git a/src/app/(pages)/(main)/category/sub-page/CategoryPage.tsx b/src/app/(pages)/(main)/category/sub-page/CategoryPage.tsx index 2386623..ec5feb0 100644 --- a/src/app/(pages)/(main)/category/sub-page/CategoryPage.tsx +++ b/src/app/(pages)/(main)/category/sub-page/CategoryPage.tsx @@ -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; dataMap:Record | undefined; + fillGreaterThan5?: boolean; } const PAGE_COMPONENTS: Partial>> = { @@ -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 = { ...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 ? : null; + return Comp ? : null; } export default CategoryPage; diff --git a/src/app/(pages)/(main)/category/sub-page/category-page/CategoryDetail.tsx b/src/app/(pages)/(main)/category/sub-page/category-page/CategoryDetail.tsx index f739155..118e5cc 100644 --- a/src/app/(pages)/(main)/category/sub-page/category-page/CategoryDetail.tsx +++ b/src/app/(pages)/(main)/category/sub-page/category-page/CategoryDetail.tsx @@ -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(filterValue as CategoryFilterValue, 500); @@ -87,6 +88,7 @@ const CategoryDetail = ({ allTableData={tableData.data} chartHeight={tableData.chartHeight} chartWidth={tableData.chartWidth} + fillGreaterThan5={fillGreaterThan5} /> ))}