260225_01_ENH: 실제 Data 통계 API와 연결 및 일부 페이지 축소

This commit is contained in:
2026-02-25 16:48:12 +09:00
parent d0e1352739
commit 357d9f2946
38 changed files with 1593 additions and 1352 deletions

View File

@@ -3,46 +3,55 @@ import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
import {CategoryTargetData} from "@/config/filter.types";
import Profile from "./category-page/Profile";
import PenetrationChange from "./category-page/PenetrationChange";
import Brand from "./category-page/Brand";
import TypeSpec from "./category-page/TypeSpec";
import OwnershipPath from "./category-page/OwnershipPath";
import PurchaseBehavior from "./category-page/PurchaseBehavior";
import PurchaseChannel from "./category-page/PurchaseChannel";
import PaymentMethod from "./category-page/PaymentMethod";
import {BannerRow, CategoryResolvedField, StatisticsRequest} from "@/types/lg";
import {useDebouncedValue} from "@/hooks/useDebouncedValue";
import {CategoryFilterValue} from "@/components/layout/CategoryFilter";
import {useMemo} from "react";
import {buildCategoryFilter, buildPageModeConfig} from "@/lib/lg-dashboard";
import {BANNER_GROUP_KEY} from "@/const/lgConst";
import {useBannerStatisticsQuery} from "@/hooks/useLgStatisticsQuery";
import CategoryDetail from "@/components/lge-dashboard/sub-page/category-page/CategoryDetail";
export type CategoryPageProps = {
fields: CategoryResolvedField[];
variableIdMap: Record<string, string>;
dataMap:Record<string, BannerRow[]> | undefined;
}
const PAGE_COMPONENTS: Partial<Record<CategoryTargetData, React.ComponentType<CategoryPageProps>>> = {
[CategoryTargetData.PROFILE]: Profile,
[CategoryTargetData.PENETRATION_CHANGE]: PenetrationChange,
[CategoryTargetData.BRAND]: CategoryDetail,
[CategoryTargetData.TYPE_SPEC]: CategoryDetail,
[CategoryTargetData.BEHAVIOR]: CategoryDetail,
[CategoryTargetData.PURCHASE_CHANNEL]: CategoryDetail,
[CategoryTargetData.PAYMENT_METHOD]: CategoryDetail,
};
const CategoryPage = () => {
const { isTotal, filterValue } = useLayoutFilter();
console.log(filterValue);
const debouncedFilterValue = useDebouncedValue<CategoryFilterValue>(filterValue as CategoryFilterValue, 500);
const renderPage = () => {
if (isTotal) return null;
const { fields, variableIdMap } = useMemo(() => {
return buildPageModeConfig(debouncedFilterValue);
}, [debouncedFilterValue]);
const target = filterValue.target;
const req = useMemo<StatisticsRequest>(() => {
return {
variableIdMap,
bannerIdList: BANNER_GROUP_KEY,
filterCondition: buildCategoryFilter(debouncedFilterValue),
option: { useCache: false, lastYear: false, decimalPoint: 0 },
};
}, [variableIdMap, debouncedFilterValue]);
switch (target) {
case CategoryTargetData.PROFILE:
return <Profile />;
case CategoryTargetData.PENETRATION_CHANGE:
return <PenetrationChange />;
case CategoryTargetData.BRAND:
return <Brand />;
case CategoryTargetData.TYPE_SPEC:
return <TypeSpec />;
case CategoryTargetData.OWNERSHIP_PATH:
return <OwnershipPath />;
case CategoryTargetData.PURCHASE_BEHAVIOR:
return <PurchaseBehavior />;
case CategoryTargetData.PURCHASE_CHANNEL:
return <PurchaseChannel />;
case CategoryTargetData.PAYMENT_METHOD:
return <PaymentMethod />;
default:
return null;
}
};
const { data } = useBannerStatisticsQuery(req);
const dataMap = data?.statisticsDataMap;
const target = debouncedFilterValue.target;
const Comp = PAGE_COMPONENTS[target.value]
return renderPage();
if(isTotal) return null;
return Comp ? <Comp fields={fields} variableIdMap={variableIdMap} dataMap={dataMap} /> : null;
}
export default CategoryPage;