diff --git a/src/app/(pages)/(main)/category/es/page.tsx b/src/app/(pages)/(main)/category/es/page.tsx index 7800595..e1e0b4b 100644 --- a/src/app/(pages)/(main)/category/es/page.tsx +++ b/src/app/(pages)/(main)/category/es/page.tsx @@ -1,4 +1,4 @@ -import CategoryPage from "@/components/lge-dashboard/sub-page/CategoryPage"; +import CategoryPage from "../sub-page/CategoryPage"; const ESPage = () => { return diff --git a/src/app/(pages)/(main)/category/kitchen/page.tsx b/src/app/(pages)/(main)/category/kitchen/page.tsx index f2c5f76..1e69608 100644 --- a/src/app/(pages)/(main)/category/kitchen/page.tsx +++ b/src/app/(pages)/(main)/category/kitchen/page.tsx @@ -1,4 +1,4 @@ -import CategoryPage from "@/components/lge-dashboard/sub-page/CategoryPage"; +import CategoryPage from "../sub-page/CategoryPage"; const KitchenPage = () => { return diff --git a/src/app/(pages)/(main)/category/living/page.tsx b/src/app/(pages)/(main)/category/living/page.tsx index 38be785..08c49e9 100644 --- a/src/app/(pages)/(main)/category/living/page.tsx +++ b/src/app/(pages)/(main)/category/living/page.tsx @@ -1,4 +1,4 @@ -import CategoryPage from "@/components/lge-dashboard/sub-page/CategoryPage"; +import CategoryPage from "../sub-page/CategoryPage"; const LivingPage = () => { return diff --git a/src/app/(pages)/(main)/category/ms/page.tsx b/src/app/(pages)/(main)/category/ms/page.tsx index bf03fe5..37fb377 100644 --- a/src/app/(pages)/(main)/category/ms/page.tsx +++ b/src/app/(pages)/(main)/category/ms/page.tsx @@ -1,4 +1,4 @@ -import CategoryPage from "@/components/lge-dashboard/sub-page/CategoryPage"; +import CategoryPage from "../sub-page/CategoryPage"; const MSPage = () => { return diff --git a/src/components/lge-dashboard/sub-page/CategoryPage.tsx b/src/app/(pages)/(main)/category/sub-page/CategoryPage.tsx similarity index 93% rename from src/components/lge-dashboard/sub-page/CategoryPage.tsx rename to src/app/(pages)/(main)/category/sub-page/CategoryPage.tsx index eee34f9..9683acd 100644 --- a/src/components/lge-dashboard/sub-page/CategoryPage.tsx +++ b/src/app/(pages)/(main)/category/sub-page/CategoryPage.tsx @@ -1,16 +1,17 @@ 'use client' + +import {useMemo} from "react"; 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 {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"; +import Profile from "./category-page/Profile"; +import PenetrationChange from "./category-page/PenetrationChange"; +import CategoryDetail from "./category-page/CategoryDetail"; +import {useBannerStatisticsQuery} from "@/query/statistics"; export type CategoryPageProps = { fields: CategoryResolvedField[]; diff --git a/src/components/lge-dashboard/sub-page/category-page/CategoryDetail.tsx b/src/app/(pages)/(main)/category/sub-page/category-page/CategoryDetail.tsx similarity index 97% rename from src/components/lge-dashboard/sub-page/category-page/CategoryDetail.tsx rename to src/app/(pages)/(main)/category/sub-page/category-page/CategoryDetail.tsx index 9b31ebb..df0e81e 100644 --- a/src/components/lge-dashboard/sub-page/category-page/CategoryDetail.tsx +++ b/src/app/(pages)/(main)/category/sub-page/category-page/CategoryDetail.tsx @@ -1,4 +1,4 @@ -import {CategoryPageProps} from "@/components/lge-dashboard/sub-page/CategoryPage"; +import {CategoryPageProps} from "../../sub-page/CategoryPage"; import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; import {useDebouncedValue} from "@/hooks/useDebouncedValue"; import {CategoryFilterValue} from "@/components/layout/CategoryFilter"; diff --git a/src/components/lge-dashboard/sub-page/category-page/PenetrationChange.tsx b/src/app/(pages)/(main)/category/sub-page/category-page/PenetrationChange.tsx similarity index 92% rename from src/components/lge-dashboard/sub-page/category-page/PenetrationChange.tsx rename to src/app/(pages)/(main)/category/sub-page/category-page/PenetrationChange.tsx index d5cbbb1..5dce4fd 100644 --- a/src/components/lge-dashboard/sub-page/category-page/PenetrationChange.tsx +++ b/src/app/(pages)/(main)/category/sub-page/category-page/PenetrationChange.tsx @@ -3,7 +3,7 @@ import BannerSummary from "@/components/lge-dashboard/combo/BannerSummary"; import {useMemo} from "react"; import {BannerRow} from "@/types/lg"; -import {CategoryPageProps} from "@/components/lge-dashboard/sub-page/CategoryPage"; +import {CategoryPageProps} from "../../sub-page/CategoryPage"; import {LAST_YEAR} from "@/const/lgConst"; const PenetrationChange = ({ diff --git a/src/components/lge-dashboard/sub-page/category-page/Profile.tsx b/src/app/(pages)/(main)/category/sub-page/category-page/Profile.tsx similarity index 96% rename from src/components/lge-dashboard/sub-page/category-page/Profile.tsx rename to src/app/(pages)/(main)/category/sub-page/category-page/Profile.tsx index 2376403..5afa434 100644 --- a/src/components/lge-dashboard/sub-page/category-page/Profile.tsx +++ b/src/app/(pages)/(main)/category/sub-page/category-page/Profile.tsx @@ -9,7 +9,7 @@ import {useDebouncedValue} from "@/hooks/useDebouncedValue"; import { calcGapBannerRow } from "@/lib/lg-dashboard"; import {YEARS} from "@/const/lgConst"; import {CategoryTargetType} from "@/config/filter.types"; -import {CategoryPageProps} from "@/components/lge-dashboard/sub-page/CategoryPage"; +import {CategoryPageProps} from "../../sub-page/CategoryPage"; const Profile = ({ dataMap diff --git a/src/app/(pages)/(main)/total/lg-penetration/page.tsx b/src/app/(pages)/(main)/total/lg-penetration/page.tsx index 3167a04..4689810 100644 --- a/src/app/(pages)/(main)/total/lg-penetration/page.tsx +++ b/src/app/(pages)/(main)/total/lg-penetration/page.tsx @@ -37,7 +37,7 @@ import {toNumOr0} from "@/lib/utils"; import {LifeStageGroup, LifeStageRow, ProductKey, StatisticsRequest} from "@/types/lg"; import {useDebouncedValue} from "@/hooks/useDebouncedValue"; import {SelectedMap} from "@/types/common"; -import {useBannerStatisticsQuery, useProductStatisticsQuery} from "@/hooks/useLgStatisticsQuery"; +import {useBannerStatisticsQuery, useProductStatisticsQuery} from "@/query/statistics"; const LGPenetrationPage = () => { const {filterValue, registerExcelExporter} = useLayoutFilter(); diff --git a/src/app/(pages)/(main)/total/lg-purchase/page.tsx b/src/app/(pages)/(main)/total/lg-purchase/page.tsx index 6d8bcc2..2d45f3f 100644 --- a/src/app/(pages)/(main)/total/lg-purchase/page.tsx +++ b/src/app/(pages)/(main)/total/lg-purchase/page.tsx @@ -27,7 +27,7 @@ import {buildHeader_ProductKeyMap, exportDashboardExcel} from "@/lib/lg-export-e import {useDebouncedValue} from "@/hooks/useDebouncedValue"; import {SelectedMap} from "@/types/common"; import {ProductKey, StatisticsRequest} from "@/types/lg"; -import {useProductStatisticsQuery} from "@/hooks/useLgStatisticsQuery"; +import {useProductStatisticsQuery} from "@/query/statistics"; import {toNumOr0} from "@/lib/utils"; const LGPurchasePage = () => { diff --git a/src/app/(pages)/(main)/total/penetration/page.tsx b/src/app/(pages)/(main)/total/penetration/page.tsx index dc6bedc..1038679 100644 --- a/src/app/(pages)/(main)/total/penetration/page.tsx +++ b/src/app/(pages)/(main)/total/penetration/page.tsx @@ -27,7 +27,7 @@ import { } from "@/lib/lg-dashboard"; import {buildHeader_ProductKeyMap, exportDashboardExcel, Section} from "@/lib/lg-export-excel"; import {StatisticsRequest} from "@/types/lg"; -import {useProductStatisticsQuery} from "@/hooks/useLgStatisticsQuery"; +import {useProductStatisticsQuery} from "@/query/statistics"; import {useDebouncedValue} from "@/hooks/useDebouncedValue"; import {toNumOr0} from "@/lib/utils"; import {SelectedMap} from "@/types/common"; diff --git a/src/app/(pages)/(main)/total/purchase/page.tsx b/src/app/(pages)/(main)/total/purchase/page.tsx index b17bba3..0c54d2c 100644 --- a/src/app/(pages)/(main)/total/purchase/page.tsx +++ b/src/app/(pages)/(main)/total/purchase/page.tsx @@ -23,7 +23,7 @@ import {buildHeader_ProductKeyMap, exportDashboardExcel} from "@/lib/lg-export-e import {useDebouncedValue} from "@/hooks/useDebouncedValue"; import {SelectedMap} from "@/types/common"; import {StatisticsRequest} from "@/types/lg"; -import {useProductStatisticsQuery} from "@/hooks/useLgStatisticsQuery"; +import {useProductStatisticsQuery} from "@/query/statistics"; const PurchasePage = () => { const { filterValue, registerExcelExporter } = useLayoutFilter(); diff --git a/src/components/lge-dashboard/table/DataTable.tsx b/src/components/lge-dashboard/table/DataTable.tsx index cae8f93..ea884bc 100644 --- a/src/components/lge-dashboard/table/DataTable.tsx +++ b/src/components/lge-dashboard/table/DataTable.tsx @@ -134,7 +134,7 @@ const DataTable = >({ const isTargetKey = (k: keyof T) => { if (!signStyle) return false; if (keys && keys.length) return keys.includes(k); - // keys 미지정이면 numeric 컬럼 전체 + // keys.ts 미지정이면 numeric 컬럼 전체 const col = columns.find((c) => c.key === k); return !!col?.numeric; }; diff --git a/src/lib/lg-export-excel.ts b/src/lib/lg-export-excel.ts index a9432ee..d956f7c 100644 --- a/src/lib/lg-export-excel.ts +++ b/src/lib/lg-export-excel.ts @@ -672,7 +672,7 @@ export function buildHeader_DataColumn(cols: DataColumn[]): HeaderBlock { * (3) BANNER_GROUP + BANNER_KEY_MAP: * - A1: "" (rowspan2) * - B1: "전체" (rowspan2) key=total - * - C1~: group(label) (colSpan = keys.length) + * - C1~: group(label) (colSpan = keys.ts.length) * - 2행: 각 key의 라벨(BANNER_KEY_MAP[key]) */ export function buildHeader_Banner( diff --git a/src/hooks/useLgStatisticsQuery.ts b/src/query/keys.ts similarity index 51% rename from src/hooks/useLgStatisticsQuery.ts rename to src/query/keys.ts index 5e47597..ce6d019 100644 --- a/src/hooks/useLgStatisticsQuery.ts +++ b/src/query/keys.ts @@ -1,6 +1,4 @@ -import { useQuery } from "@tanstack/react-query"; -import type { StatisticsRequest, ProductResponse, BannerResponse } from "@/types/lg"; -import {fetchBannerStatistics, fetchProductStatistics} from "@/lib/lg-dashboard"; +import type {ProductResponse, StatisticsRequest} from "@/types/lg"; const sortRecord = (obj?: Record | null): Record => { if (!obj) return {}; @@ -20,7 +18,6 @@ const sortNumberArrayRecord = (obj?: Record | null): Record ({ variableIdMap: sortRecord(req.variableIdMap), bannerIdList: [...(req.bannerIdList ?? [])].sort(), @@ -32,28 +29,4 @@ export const productStatisticsKey = (req: StatisticsRequest) => ["statistics", "product", normalizeReqForKey(req)] as const; export const bannerStatisticsKey = (req: StatisticsRequest) => - ["statistics", "banner", normalizeReqForKey(req)] as const; - -export function useProductStatisticsQuery(req: StatisticsRequest, enabled = true) { - return useQuery({ - queryKey: productStatisticsKey(req), - queryFn: () => fetchProductStatistics(req), - enabled, - staleTime: 60_000, - gcTime: 10 * 60_000, - }); -} - -export function useBannerStatisticsQuery(req: StatisticsRequest, enabled = true) { - return useQuery({ - queryKey: bannerStatisticsKey(req), - queryFn: () => fetchBannerStatistics(req), - enabled, - /* - refetchOnMount: "always", - staleTime: 0, - */ - staleTime: 60_000, - gcTime: 10 * 60_000, - }); -} \ No newline at end of file + ["statistics", "banner", normalizeReqForKey(req)] as const; \ No newline at end of file diff --git a/src/query/statistics.ts b/src/query/statistics.ts new file mode 100644 index 0000000..28ff5a1 --- /dev/null +++ b/src/query/statistics.ts @@ -0,0 +1,28 @@ +import {BannerResponse, ProductResponse, StatisticsRequest} from "@/types/lg"; +import {useQuery} from "@tanstack/react-query"; +import {bannerStatisticsKey, productStatisticsKey} from "@/query/keys"; +import {fetchBannerStatistics, fetchProductStatistics} from "@/lib/lg-dashboard"; + +export function useProductStatisticsQuery(req: StatisticsRequest, enabled = true) { + return useQuery({ + queryKey: productStatisticsKey(req), + queryFn: () => fetchProductStatistics(req), + enabled, + staleTime: 60_000, + gcTime: 10 * 60_000, + }); +} + +export function useBannerStatisticsQuery(req: StatisticsRequest, enabled = true) { + return useQuery({ + queryKey: bannerStatisticsKey(req), + queryFn: () => fetchBannerStatistics(req), + enabled, + /* + refetchOnMount: "always", + staleTime: 0, + */ + staleTime: 60_000, + gcTime: 10 * 60_000, + }); +} \ No newline at end of file