diff --git a/src/app/(pages)/(main)/category/[category]/brand/page.tsx b/src/app/(pages)/(main)/category/[category]/brand/page.tsx new file mode 100644 index 0000000..ce8859f --- /dev/null +++ b/src/app/(pages)/(main)/category/[category]/brand/page.tsx @@ -0,0 +1,12 @@ +'use client' + +import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; + +const BrandPage = () => { + const { categoryValue } = useLayoutFilter(); + console.log(categoryValue); + + return
Brand
; +} + +export default BrandPage; \ No newline at end of file diff --git a/src/app/(pages)/(main)/category/[category]/ownership-path/page.tsx b/src/app/(pages)/(main)/category/[category]/ownership-path/page.tsx new file mode 100644 index 0000000..a48bea3 --- /dev/null +++ b/src/app/(pages)/(main)/category/[category]/ownership-path/page.tsx @@ -0,0 +1,12 @@ +'use client' + +import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; + +const OwnershipPathPage = () => { + const { categoryValue } = useLayoutFilter(); + console.log(categoryValue); + + return
ownership path
; +}; + +export default OwnershipPathPage; \ No newline at end of file diff --git a/src/app/(pages)/(main)/category/[category]/penetration-change/page.tsx b/src/app/(pages)/(main)/category/[category]/penetration-change/page.tsx new file mode 100644 index 0000000..6dea644 --- /dev/null +++ b/src/app/(pages)/(main)/category/[category]/penetration-change/page.tsx @@ -0,0 +1,12 @@ +'use client' + +import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; + +const PenetrationChangePage = () => { + const { categoryValue } = useLayoutFilter(); + console.log(categoryValue); + + return
PenetrationChange
+} + +export default PenetrationChangePage \ No newline at end of file diff --git a/src/app/(pages)/(main)/category/[category]/profile/page.tsx b/src/app/(pages)/(main)/category/[category]/profile/page.tsx new file mode 100644 index 0000000..3e655a9 --- /dev/null +++ b/src/app/(pages)/(main)/category/[category]/profile/page.tsx @@ -0,0 +1,12 @@ +'use client' + +import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; + +const ProfilePage = () => { + const { categoryValue } = useLayoutFilter(); + console.log(categoryValue); + + return
Profile
+} + +export default ProfilePage; \ No newline at end of file diff --git a/src/app/(pages)/(main)/category/[category]/purchase-behavior/page.tsx b/src/app/(pages)/(main)/category/[category]/purchase-behavior/page.tsx new file mode 100644 index 0000000..e5780d9 --- /dev/null +++ b/src/app/(pages)/(main)/category/[category]/purchase-behavior/page.tsx @@ -0,0 +1,12 @@ +'use client' + +import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; + +const PurchaseBehaviorPage = () => { + const { categoryValue } = useLayoutFilter(); + console.log(categoryValue); + + return
PurchaseBehavior
; +}; + +export default PurchaseBehaviorPage; \ No newline at end of file diff --git a/src/app/(pages)/(main)/category/[category]/purchase-channel/page.tsx b/src/app/(pages)/(main)/category/[category]/purchase-channel/page.tsx new file mode 100644 index 0000000..19290b8 --- /dev/null +++ b/src/app/(pages)/(main)/category/[category]/purchase-channel/page.tsx @@ -0,0 +1,12 @@ +'use client' + +import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; + +const PurchaseChannelPage = () => { + const { categoryValue } = useLayoutFilter(); + console.log(categoryValue); + + return
PurchaseChannel
; +}; + +export default PurchaseChannelPage; \ No newline at end of file diff --git a/src/app/(pages)/(main)/category/[category]/purchase-format/page.tsx b/src/app/(pages)/(main)/category/[category]/purchase-format/page.tsx new file mode 100644 index 0000000..df262f5 --- /dev/null +++ b/src/app/(pages)/(main)/category/[category]/purchase-format/page.tsx @@ -0,0 +1,12 @@ +'use client' + +import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; + +const PurchaseFormatPage = () => { + const { categoryValue } = useLayoutFilter(); + console.log(categoryValue); + + return
PurchaseFormat
+} + +export default PurchaseFormatPage; \ No newline at end of file diff --git a/src/app/(pages)/(main)/category/[category]/type-spec/page.tsx b/src/app/(pages)/(main)/category/[category]/type-spec/page.tsx new file mode 100644 index 0000000..2997be4 --- /dev/null +++ b/src/app/(pages)/(main)/category/[category]/type-spec/page.tsx @@ -0,0 +1,12 @@ +'use client' + +import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; + +const TypeSpecPage = () => { + const { categoryValue } = useLayoutFilter(); + console.log(categoryValue); + + return
TypeSpec
+} + +export default TypeSpecPage; \ No newline at end of file diff --git a/src/app/(pages)/(main)/category/air-solution/page.tsx b/src/app/(pages)/(main)/category/air-solution/page.tsx deleted file mode 100644 index cdb55b9..0000000 --- a/src/app/(pages)/(main)/category/air-solution/page.tsx +++ /dev/null @@ -1,9 +0,0 @@ -'use client' - -const AirSolutionPage = () => { - return ( -
AirSolutionPage
- ); -} - -export default AirSolutionPage; \ No newline at end of file diff --git a/src/app/(pages)/(main)/category/ha-kitchen/page.tsx b/src/app/(pages)/(main)/category/ha-kitchen/page.tsx deleted file mode 100644 index ea21e74..0000000 --- a/src/app/(pages)/(main)/category/ha-kitchen/page.tsx +++ /dev/null @@ -1,11 +0,0 @@ -'use client' - -const HAKitchenPage = () => { - return ( -
-
HAKitchenPage
-
- ); -} - -export default HAKitchenPage; \ No newline at end of file diff --git a/src/app/(pages)/(main)/category/ha-living/page.tsx b/src/app/(pages)/(main)/category/ha-living/page.tsx deleted file mode 100644 index e5491e2..0000000 --- a/src/app/(pages)/(main)/category/ha-living/page.tsx +++ /dev/null @@ -1,9 +0,0 @@ -'use client' - -const HALivingPage = () => { - return ( -
HALivingPage
- ); -} - -export default HALivingPage; \ No newline at end of file diff --git a/src/app/(pages)/(main)/category/ms-digital/page.tsx b/src/app/(pages)/(main)/category/ms-digital/page.tsx deleted file mode 100644 index 6373de2..0000000 --- a/src/app/(pages)/(main)/category/ms-digital/page.tsx +++ /dev/null @@ -1,9 +0,0 @@ -'use client' - -const MSDigitalPage = () => { - return ( -
MSDigitalPage
- ); -} - -export default MSDigitalPage; \ No newline at end of file diff --git a/src/app/(pages)/(main)/total/lg-penetration/page.tsx b/src/app/(pages)/(main)/total/lg-penetration/page.tsx index 8f5b961..c0f007e 100644 --- a/src/app/(pages)/(main)/total/lg-penetration/page.tsx +++ b/src/app/(pages)/(main)/total/lg-penetration/page.tsx @@ -1,20 +1,21 @@ 'use client' import { - GaugeCardTable, GaugeColumn, - GroupedOverlayBar, GroupedOverlayBarData, LifeStageRow, + GroupedOverlayBar, GroupedOverlayBarData, signStyleGapRow, TopChartTable, TopChartTableRow } from "@/components/lge-dashboard"; import {PRODUCT_KEYS, PRODUCTS, YEARS} from "@/const/lgConst"; import {useMemo} from "react"; import { - apiLifeStageByProduct, - apiLifeStageByProductForGauge, apiOwnShareOfTotalPenetration, apiTrendCategories } from "@/config/sample.data"; +import LifeStageDiv from "@/components/lge-dashboard/sub-page/LifeStageDiv"; +import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; const LGPenetrationPage = () => { + const { totalValue } = useLayoutFilter(); + console.log(totalValue); const displayRowLabel = (i:number, rowLabel: string) => { if (rowLabel === "gap") return "전년 대비 GAP(%)"; @@ -57,52 +58,7 @@ const LGPenetrationPage = () => { focus: focus, } - const norm = (s: string) => s.replace(/\s+/g, "").toLowerCase(); - const asNum = (v: unknown): number | null => typeof v === "number" && Number.isFinite(v) ? v : null; - const LIFE_STAGE_COLUMNS: GaugeColumn[] = [ - { key: "item", header: "", rowHead: true, renderLabel: (r) => r.item }, - - { key: "total", header: "전체", max: 100, align: "left", cellType:"number"}, - { key: "single", header: "미혼", max: 100 , align: "left"}, - - { key: "noKids", header: "무자녀", group: "기혼", max: 100 , align: "left"}, - { key: "preschoolKids", header: "미취학", group: "기혼", max: 100 , align: "left"}, - { key: "schoolKids", header: "취학자녀", group: "기혼", max: 100 , align: "left"}, - { key: "adultKids", header: "성인자녀", group: "기혼", max: 100 , align: "left"}, - - { key: "independentSenior", header: "독립\n시니어", max: 100 , align: "left"}, - ]; - - const LIFE_STAGE_GROUPS = [ - { title: "필수가전 군", items: ["냉장고", "세탁기", "에어컨", "TV", "청소기", "김치 냉장고"] }, - { title: "케어가전 군", items: ["공기 청정기", "가습기", "제습기"] }, - { title: "Must & Best", items: ["건조기", "식기 세척기", "의류 관리기"] }, - { title: "신가전 군", items: ["로봇 청소기"] }, - ] as const; - - const lifeStageRowsByGroup = useMemo(() => { - const pick = (label: string) => apiLifeStageByProduct.find((r) => norm(r.rowLabel) === norm(label)); - - return LIFE_STAGE_GROUPS.map((g) => { - const rows: LifeStageRow[] = g.items.map((label) => { - const r = pick(label); - - return { - item: label, - total: asNum((r as any)?.total), // 서버에 all이 없으면 null로 남음 - single: asNum((r as any)?.single), - noKids: asNum((r as any)?.noKids), - preschoolKids: asNum((r as any)?.preschoolKids), - schoolKids: asNum((r as any)?.schoolKids), - adultKids: asNum((r as any)?.adultKids), - independentSenior: asNum((r as any)?.independentSenior), - }; - }); - - return { title: g.title, rows }; - }); - }, []); return (
@@ -121,33 +77,7 @@ const LGPenetrationPage = () => { signStyle={signStyleGapRow} /> -
-
-
- - 제품 보유율 -
- -
- - 시장 기회공간 -
-
- -
- {lifeStageRowsByGroup.map((g) => ( - - ))} -
-
+
); diff --git a/src/app/(pages)/(main)/total/lg-purchase/page.tsx b/src/app/(pages)/(main)/total/lg-purchase/page.tsx index 6bfa280..1c03dc8 100644 --- a/src/app/(pages)/(main)/total/lg-purchase/page.tsx +++ b/src/app/(pages)/(main)/total/lg-purchase/page.tsx @@ -10,8 +10,12 @@ import { TopChartTableRow } from "@/components/lge-dashboard"; import { apiOwnShareOfTotalPurchase, apiTrendBuy} from "@/config/sample.data"; +import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; const LGPurchasePage = () => { + const { totalValue } = useLayoutFilter(); + console.log(totalValue); + const displayRowLabel = (i:number, rowLabel: string) => { if (rowLabel === "gap") return "전년 대비 GAP(%)"; return rowLabel; diff --git a/src/app/(pages)/(main)/total/penetration/page.tsx b/src/app/(pages)/(main)/total/penetration/page.tsx index 3a1988d..ee99f84 100644 --- a/src/app/(pages)/(main)/total/penetration/page.tsx +++ b/src/app/(pages)/(main)/total/penetration/page.tsx @@ -15,6 +15,8 @@ import {BRAND_LIST, PRODUCT_KEYS, PRODUCTS, YEARS, AXIS_HIDE_STYLE, GRID_X_NOT_P const PenetrationPage = () => { const { totalValue, registerExcelExporter } = useLayoutFilter(); + console.log(totalValue); + const [isBrandShare, setIsBrandShare] = useState(false); const displayRowLabel = (i:number, rowLabel: string) => { diff --git a/src/app/(pages)/(main)/total/purchase/page.tsx b/src/app/(pages)/(main)/total/purchase/page.tsx index 000570f..806015a 100644 --- a/src/app/(pages)/(main)/total/purchase/page.tsx +++ b/src/app/(pages)/(main)/total/purchase/page.tsx @@ -7,8 +7,12 @@ import { TopChartTableRow, VerticalBar } from "@/components/lge-dashboard"; import {apiTrendBuy} from "@/config/sample.data"; +import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; const PurchasePage = () => { + const { totalValue } = useLayoutFilter(); + console.log(totalValue); + const displayRowLabel = (i:number, rowLabel: string) => { if (rowLabel === "gap") return "전년 대비 GAP(%)"; return rowLabel; diff --git a/src/app/layout.tsx b/src/app/layout.tsx index cb5e958..36df37a 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -2,6 +2,7 @@ import type { Metadata } from "next"; import { Geist, Geist_Mono } from "next/font/google"; import "./globals.css"; import {Toaster} from "sonner"; +import {AppProvider} from "@/components/providers/AppProvider"; const geistSans = Geist({ variable: "--font-geist-sans", @@ -25,10 +26,10 @@ const RootLayout = ({ }>) => { return ( - - {children} - - + + {children} + + ); }; diff --git a/src/components/common/LoadingOverlay.tsx b/src/components/common/LoadingOverlay.tsx new file mode 100644 index 0000000..cfc21aa --- /dev/null +++ b/src/components/common/LoadingOverlay.tsx @@ -0,0 +1,17 @@ +"use client"; + +import { useAtomValue } from "jotai"; +import { loadingAtom } from "@/store/jotai/loading"; + +export function LoadingOverlay({ force = false }: { force?: boolean }) { + const isLoading = useAtomValue(loadingAtom); + + if (!force && !isLoading) return null; + + return ( +
+ {/* 심플 로딩 인디케이터 */} +
+
+ ); +} \ No newline at end of file diff --git a/src/components/layout/CategoryFilter.tsx b/src/components/layout/CategoryFilter.tsx index 127b13b..41ec42f 100644 --- a/src/components/layout/CategoryFilter.tsx +++ b/src/components/layout/CategoryFilter.tsx @@ -6,14 +6,7 @@ import { ChevronRight } from "lucide-react"; import { useMemo } from "react"; import { cn } from "@/lib/utils"; import { Button } from "@/components/ui/button"; - -const PRODUCTS = [ - { value: "냉장고", label: "냉장고" }, - { value: "세탁기", label: "세탁기" }, - { value: "식기세척기", label: "식기세척기" }, - { value: "건조기", label: "건조기" }, - { value: "에어컨", label: "에어컨" }, -] as const; +import {ProductsFilterItem} from "@/types/lg"; export type CategoryTypeValue = { label: string; @@ -27,13 +20,13 @@ export type CategoryFilterValue = { }; type CategoryFilterProps = { + filterItems: ProductsFilterItem, value: CategoryFilterValue; onChange: (next: CategoryFilterValue) => void; className?: string; }; -const CategoryFilter = ({ value, onChange, className }: CategoryFilterProps) => { - +const CategoryFilter = ({ filterItems, value, onChange, className }: CategoryFilterProps) => { const currentTargetItem = useMemo(() => { return categoryTarget.find((item) => item.type === value.type.value); }, [value.type]); @@ -46,8 +39,8 @@ const CategoryFilter = ({ value, onChange, className }: CategoryFilterProps) => const next: CategoryFilterValue = { ...value, [key]: v } as CategoryFilterValue; - if (key === "type") { - const nextItem = categoryTarget.find((item) => item.type === v); + if (key === "type" && typeof v === "object" && v.value !== value.type.value) { + const nextItem = categoryTarget.find((item) => item.type === v.value); const firstTarget = nextItem?.children?.[0]?.target; if (firstTarget) next.target = firstTarget; } @@ -66,17 +59,17 @@ const CategoryFilter = ({ value, onChange, className }: CategoryFilterProps) =>
- {PRODUCTS.map((p) => { - const active = value.product === p.value; + {filterItems.items.map((p) => { + const active = value.product === p; return ( ); })} diff --git a/src/components/layout/MainLayout.tsx b/src/components/layout/MainLayout.tsx index fccace4..d3057d7 100644 --- a/src/components/layout/MainLayout.tsx +++ b/src/components/layout/MainLayout.tsx @@ -1,11 +1,11 @@ "use client"; -import {ReactNode, useState} from "react"; +import {ReactNode, useEffect, useMemo, useState} from "react"; import { usePathname, useRouter } from "next/navigation"; import {cn} from "@/lib/utils"; import {SelectedMap} from "@/types/common"; import {topMenus, totalSubMenus, categorySubMenus} from "@/config/menu.data"; -import {categoryTarget, totalFilters} from "@/config/filter.data"; +import {categoryTarget, TARGET_SLUG, totalFilters} from "@/config/filter.data"; import {CategoryTargetData, CategoryTargetType} from "@/config/filter.types"; import Header from "./Header"; import SubMenu from "./SubMenu"; @@ -13,6 +13,9 @@ import TotalFilter from "./TotalFilter"; import CategoryFilter, {CategoryFilterValue} from "./CategoryFilter"; import ExcelDownloadButton from "./ExcelDownloadButton"; import {LayoutFilterProvider} from "./LayoutFilterContext"; +import {PRODUCTS_FILTER_ITEM} from "@/const/lgConst"; +import {ProductsFilterItem} from "@/types/lg"; +import {useLoading} from "@/hooks/useLoading"; type MainLayoutProps = { children: ReactNode; @@ -28,43 +31,79 @@ const buildDefaultTotalValue = (): SelectedMap => { return init; }; -export const buildDefaultCategoryValue = (): CategoryFilterValue => { +export const buildDefaultCategoryValue = (categoryFilterItems: ProductsFilterItem): CategoryFilterValue => { + const initProduct = categoryFilterItems.items[0]; const initType = {label:"보유", value:CategoryTargetType.PENETRATION} const firstTarget = categoryTarget.find((x) => x.type === initType.value)?.children?.[0]?.target; + const initTarget = firstTarget ?? CategoryTargetData.PROFILE; return { - product: "냉장고", + product: initProduct, type: initType, - target: firstTarget ?? CategoryTargetData.PROFILE, + target: initTarget, }; }; - const MainLayout = ({ children }: MainLayoutProps) => { const router = useRouter(); const pathname = usePathname(); + const { withLoadingAsync } = useLoading(); const isTotal = pathname.startsWith("/total"); const activeTop = topMenus.find((m) => m.match?.(pathname)) ?? topMenus[0]; const subMenus = isTotal ? totalSubMenus : categorySubMenus; - const activeSub = subMenus.find((m) => m.path.startsWith(pathname)) ?? subMenus[0]; + const activeSub = subMenus.find((m) => pathname.startsWith(m.path)) ?? subMenus[0]; const [isTotalFilterOpen, setIsTotalFilterOpen] = useState(true); const [isCategoryFilterOpen, setIsCategoryFilterOpen] = useState(true); const isFilterOpen = isTotal ? isTotalFilterOpen : isCategoryFilterOpen; + const categoryFilterItems = PRODUCTS_FILTER_ITEM.find((m) => pathname.match?.(m.path)) ?? PRODUCTS_FILTER_ITEM[0]; + const [totalValue, setTotalValue] = useState(() => buildDefaultTotalValue()); - const [categoryValue, setCategoryValue] = useState(() => buildDefaultCategoryValue()); + const [categoryValue, setCategoryValue] = useState(() => buildDefaultCategoryValue(categoryFilterItems)); const movePage = (path: string) => { router.push(path); }; + const moveCategoryPage = (path: string) => { + const slug = TARGET_SLUG[categoryValue.target] ?? "profile"; + const nextPath = `${path}/${slug}`; + + if (pathname !== nextPath) { + router.push(nextPath); + } + } + const toggleFilter = () => { if (isTotal) setIsTotalFilterOpen((v) => !v); else setIsCategoryFilterOpen((v) => !v); }; + useEffect(() => { + /* + withLoadingAsync(async () => { + setCategoryValue(prev => ({...prev, product: categoryFilterItems.items[0]})) + }); + */ + setCategoryValue(prev => ({...prev, product: categoryFilterItems.items[0]})) + }, [categoryFilterItems]); + + useEffect(() => { + if (isTotal) return; + + const base = activeSub?.path; // "/category/ha-kitchen" + if (!base) return; + + const slug = TARGET_SLUG[categoryValue.target] ?? "profile"; + const nextPath = `${base}/${slug}`; + + if (pathname !== nextPath) { + router.replace(nextPath); + } + }, [isTotal, categoryValue.target, activeSub?.path, pathname, router]); + return (
{
@@ -106,7 +145,7 @@ const MainLayout = ({ children }: MainLayoutProps) => { {isTotal ? ( ) : ( - + )}
)} diff --git a/src/components/lge-dashboard/SectionTitle.tsx b/src/components/lge-dashboard/SectionTitle.tsx new file mode 100644 index 0000000..4edcc90 --- /dev/null +++ b/src/components/lge-dashboard/SectionTitle.tsx @@ -0,0 +1,10 @@ +const SectionTitle = ({title}:{title:string}) => { + return ( +
+ + {title} +
+ ); +} + +export default SectionTitle; diff --git a/src/components/lge-dashboard/combo/LeftChartTable.tsx b/src/components/lge-dashboard/combo/LeftChartTable.tsx index 034f217..5f7e4db 100644 --- a/src/components/lge-dashboard/combo/LeftChartTable.tsx +++ b/src/components/lge-dashboard/combo/LeftChartTable.tsx @@ -3,6 +3,7 @@ import React, { useMemo } from "react"; import { cn } from "@/lib/utils"; import type { DataColumn, SignStyle } from "../types"; +import SectionTitle from "../SectionTitle"; type MergedChartCell = { /** 차트를 삽입할 컬럼 key(해당 컬럼 td는 startRow에서만 렌더되고 rowSpan 적용) */ @@ -143,10 +144,7 @@ export default function LeftChartTable>({ return (
{title && ( -
- - {title} -
+ )}
diff --git a/src/components/lge-dashboard/combo/TopChartTable.tsx b/src/components/lge-dashboard/combo/TopChartTable.tsx index 2360022..cf5551f 100644 --- a/src/components/lge-dashboard/combo/TopChartTable.tsx +++ b/src/components/lge-dashboard/combo/TopChartTable.tsx @@ -3,6 +3,7 @@ import React, { useMemo } from "react"; import { cn } from "@/lib/utils"; import type { ChartData, SignStyle, TopChartTableRow } from "../types"; +import SectionTitle from "../SectionTitle"; type BaseProps = { title?: string; @@ -135,10 +136,7 @@ export default function TopChartTable(props: TopChartTableProps) { return (
{title && ( -
- - {title} -
+ )}
diff --git a/src/components/lge-dashboard/index.ts b/src/components/lge-dashboard/index.ts index d059e57..9b4269d 100644 --- a/src/components/lge-dashboard/index.ts +++ b/src/components/lge-dashboard/index.ts @@ -14,6 +14,8 @@ export { default as GaugeTable } from "./table/GaugeTable"; export { default as TopChartTable } from "./combo/TopChartTable"; export { default as LeftChartTable } from "./combo/LeftChartTable"; export { default as GaugeCardTable } from "./combo/GaugeCardTable"; -export { default as CategoryByData } from "./combo/CategoryByData" +export { default as CategoryByData } from "./sub-page/CategoryByData" export { default as CardDefault } from "./card/Card"; + +export { default as SectionTitle } from "./SectionTitle"; diff --git a/src/components/lge-dashboard/combo/CategoryByData.tsx b/src/components/lge-dashboard/sub-page/CategoryByData.tsx similarity index 100% rename from src/components/lge-dashboard/combo/CategoryByData.tsx rename to src/components/lge-dashboard/sub-page/CategoryByData.tsx diff --git a/src/components/lge-dashboard/sub-page/LifeStageDiv.tsx b/src/components/lge-dashboard/sub-page/LifeStageDiv.tsx new file mode 100644 index 0000000..ded82dc --- /dev/null +++ b/src/components/lge-dashboard/sub-page/LifeStageDiv.tsx @@ -0,0 +1,85 @@ +import GaugeCardTable from "../combo/GaugeCardTable"; +import {GaugeColumn} from "@/components/lge-dashboard"; +import {useMemo} from "react"; +import {apiLifeStageByProduct} from "@/config/sample.data"; +import {LifeStageRow} from "@/types/lg"; + +const LifeStageDiv = () => { + const norm = (s: string) => s.replace(/\s+/g, "").toLowerCase(); + const asNum = (v: unknown): number | null => typeof v === "number" && Number.isFinite(v) ? v : null; + + const LIFE_STAGE_COLUMNS: GaugeColumn[] = [ + { key: "item", header: "", rowHead: true, renderLabel: (r) => r.item }, + + { key: "total", header: "전체", max: 100, align: "left", cellType:"number"}, + { key: "single", header: "미혼", max: 100 , align: "left"}, + + { key: "noKids", header: "무자녀", group: "기혼", max: 100 , align: "left"}, + { key: "preschoolKids", header: "미취학", group: "기혼", max: 100 , align: "left"}, + { key: "schoolKids", header: "취학자녀", group: "기혼", max: 100 , align: "left"}, + { key: "adultKids", header: "성인자녀", group: "기혼", max: 100 , align: "left"}, + + { key: "independentSenior", header: "독립\n시니어", max: 100 , align: "left"}, + ]; + + const LIFE_STAGE_GROUPS = [ + { title: "대형가전 군", items: ["냉장고", "세탁기", "건조기", "에어컨", "TV", "김치 냉장고", "식기세척기", "의류 관리기"] }, + { title: "소형가전 군", items: ["청소기", "공기 청정기", "정수기"] }, + { title: "신가전 군", items: ["로봇 청소기", "음식물처리기"] }, + ] as const; + + const lifeStageRowsByGroup = useMemo(() => { + const pick = (label: string) => apiLifeStageByProduct.find((r) => norm(r.rowLabel) === norm(label)); + + return LIFE_STAGE_GROUPS.map((g) => { + const rows: LifeStageRow[] = g.items.map((label) => { + const r = pick(label); + + return { + item: label, + total: asNum((r as any)?.total), // 서버에 all이 없으면 null로 남음 + single: asNum((r as any)?.single), + noKids: asNum((r as any)?.noKids), + preschoolKids: asNum((r as any)?.preschoolKids), + schoolKids: asNum((r as any)?.schoolKids), + adultKids: asNum((r as any)?.adultKids), + independentSenior: asNum((r as any)?.independentSenior), + }; + }); + + return { title: g.title, rows }; + }); + }, []); + + return ( +
+
+
+ + 제품 보유율 +
+ +
+ + 시장 기회공간 +
+
+ +
+ {lifeStageRowsByGroup.map((g) => ( + + ))} +
+
+ ); +} + +export default LifeStageDiv; \ No newline at end of file diff --git a/src/components/lge-dashboard/table/GaugeTable.tsx b/src/components/lge-dashboard/table/GaugeTable.tsx index 83c5bd8..d8252b1 100644 --- a/src/components/lge-dashboard/table/GaugeTable.tsx +++ b/src/components/lge-dashboard/table/GaugeTable.tsx @@ -142,7 +142,7 @@ const GaugeTable = >({ v === null ? undefined : `linear-gradient(to right, ${fill} ${pct}%, ${track} 0%)`; -console.log(cellBg); + if (cellType === "number") { return ( >; - -// { year, rowLabel, total, ...banner } -// (배너는 기본 41개 키 + 차트별 추가 키가 생길 수 있으니 확장 허용) -export type ServerBannerRow = ServerBaseRow & - Partial> & { - [k: string]: number | string; -}; - -export type LifeStageRow = Record & { - item: string; - total: number | null; - single: number | null; - noKids: number | null; - preschoolKids: number | null; - schoolKids: number | null; - adultKids: number | null; - independentSenior: number | null; -}; - export type ChartSeries = { /** legend에 노출될 이름 */ name: string; diff --git a/src/components/providers/AppProvider.tsx b/src/components/providers/AppProvider.tsx new file mode 100644 index 0000000..3f30ca3 --- /dev/null +++ b/src/components/providers/AppProvider.tsx @@ -0,0 +1,11 @@ +import { Provider as JotaiProvider } from "jotai"; +import {LoadingOverlay} from "@/components/common/LoadingOverlay"; + +export function AppProvider({ children }: { children: React.ReactNode }) { + return ( + + + {children} + + ); +} \ No newline at end of file diff --git a/src/config/filter.data.ts b/src/config/filter.data.ts index aa79aea..4129653 100644 --- a/src/config/filter.data.ts +++ b/src/config/filter.data.ts @@ -141,4 +141,15 @@ export const categoryTarget: CategoryTargetItem[] = [ { target: CategoryTargetData.PURCHASE_FORMAT, label: "구매 형식"}, ] }, -] \ No newline at end of file +] + +export const TARGET_SLUG: Record = { + [CategoryTargetData.PROFILE]: "profile", + [CategoryTargetData.BRAND]: "brand", + [CategoryTargetData.TYPE_SPEC]: "type-spec", + [CategoryTargetData.PURCHASE_FORMAT]: "purchase-format", + [CategoryTargetData.PENETRATION_CHANGE]: "penetration-change", + [CategoryTargetData.OWNERSHIP_PATH]: "ownership-path", + [CategoryTargetData.PURCHASE_BEHAVIOR]: "purchase-behavior", + [CategoryTargetData.PURCHASE_CHANNEL]: "purchase-channel", +}; \ No newline at end of file diff --git a/src/config/menu.data.ts b/src/config/menu.data.ts index d10eeb5..5b9e91c 100644 --- a/src/config/menu.data.ts +++ b/src/config/menu.data.ts @@ -10,7 +10,7 @@ export const topMenus: TopMenuItem[] = [ { id: "category", label: "카테고리", - path: "/category/ha-kitchen", + path: "/category/ha-kitchen/profile", match: (pathname) => pathname.startsWith("/category"), }, ]; diff --git a/src/config/sample.data.ts b/src/config/sample.data.ts index 025d986..d64455b 100644 --- a/src/config/sample.data.ts +++ b/src/config/sample.data.ts @@ -1,11 +1,7 @@ // sample.data.ts -import { - ProductKey, - BannerKey, - ServerBannerRow, - ServerProductRow, -} from "@/components/lge-dashboard"; -import {PRODUCT_KEY_MAP} from "@/components/lge-dashboard"; + +import {PRODUCT_KEY_MAP} from "@/const/lgConst"; +import {BannerKey, ProductKey, ServerBannerRow, ServerProductRow} from "@/types/lg"; const PRODUCT_KEYS = Object.keys(PRODUCT_KEY_MAP) as ProductKey[]; @@ -270,36 +266,23 @@ export const apiOwnShareOfTotalPurchase: ServerProductRow[] = [ ]; export const apiLifeStageByProduct: ServerBannerRow[] = [ - bannerRow(26, "냉장고", 1200), - bannerRow(26, "세탁기", 1100), - bannerRow(26, "에어컨", 900), - bannerRow(26, "TV", 950), - bannerRow(26, "청소기", 1000), - bannerRow(26, "김치 냉장고", 700), - bannerRow(26, "공기 청정기", 800), - bannerRow(26, "가습기", 650), - bannerRow(26, "제습기", 600), - bannerRow(26, "건조기", 500), - bannerRow(26, "식기세척기", 450), - bannerRow(26, "의류 관리기", 320), - bannerRow(26, "로봇 청소기", 420), -]; - -export const apiLifeStageByProductForGauge: ServerBannerRow[] = [ bannerRow(26, "냉장고", 1200, {min:10, max:99}), bannerRow(26, "세탁기", 1100, {min:10, max:99}), bannerRow(26, "에어컨", 900, {min:10, max:99}), - bannerRow(26, "TV", 950, {min:10, max:99}), - bannerRow(26, "청소기", 1000, {min:10, max:99}), - bannerRow(26, "김치 냉장고", 700, {min:10, max:99}), - bannerRow(26, "공기 청정기", 800, {min:10, max:99}), - bannerRow(26, "가습기", 650, {min:10, max:99}), - bannerRow(26, "제습기", 600, {min:10, max:99}), bannerRow(26, "건조기", 500, {min:10, max:99}), + bannerRow(26, "TV", 950, {min:10, max:99}), + bannerRow(26, "김치 냉장고", 700, {min:10, max:99}), bannerRow(26, "식기세척기", 450, {min:10, max:99}), bannerRow(26, "의류 관리기", 320, {min:10, max:99}), + + bannerRow(26, "청소기", 1000, {min:10, max:99}), + bannerRow(26, "공기 청정기", 800, {min:10, max:99}), + bannerRow(26, "정수기", 800, {min:10, max:99}), + bannerRow(26, "로봇 청소기", 420, {min:10, max:99}), + bannerRow(26, "음식물처리기", 420, {min:10, max:99}), ]; + /** --------------------------- * API #6 * year rowLabel total banner diff --git a/src/const/lgConst.ts b/src/const/lgConst.ts index 3b9f0f9..6e5b4b4 100644 --- a/src/const/lgConst.ts +++ b/src/const/lgConst.ts @@ -1,4 +1,93 @@ -import {PRODUCT_KEY_MAP} from "@/components/lge-dashboard"; +export const PRODUCT_KEY_MAP = { + washingMachine: "세탁기", + refrigerator: "냉장고", + airConditioner: "에어컨", + tv: "TV", + microwave: "전자 레인지", + vacuumCleaner: "청소기", + laptop: "노트북", + kimchiRefrigerator: "김치 냉장고", + airFryer: "에어 프라이어", + tablet: "태블릿", + waterPurifier: "정수기", + monitor: "모니터", + airPurifier: "공기 청정기", + dryer: "건조기", + electricRange: "전기 레인지", + humidifier: "가습기", + dehumidifier: "제습기", + oven: "오븐", + robotVacuum: "로봇 청소기", + dishwasher: "식기 세척기", + massageChair: "안마 의자", + clothingCareSystem: "의류 관리기", + foodWasteDisposer: "음식물처리기", + projector: "빔프로젝터", + comboAirCareProduct: "복합 에어케어 제품", + ventilationSystem: "환기 시스템", + wineCellar: "와인 셀러", + premiumBathroomVentFan: "프리미엄 욕실 환풍기", + shoeCareSystem: "신발 관리기", +} as const; + +export const BANNER_KEY_MAP = { + // 라이프 스테이지 + single: "미혼", + noKids: "무자녀", + preschoolKids: "미취학", + schoolKids: "취학자녀", + adultKids: "성인자녀", + independentSenior: "독립시니어", + + // 가구원수 + hh1: "1인 가구", + hh2: "2인 가구", + hh3: "3인 가구", + hh4Plus: "4인 이상 가구", + + // 연령 + age20s: "20대", + age30s: "30대", + age40s: "40대", + age50s: "50대", + age60s: "60대", + + // 점유형태 + ownerOccupied: "자가", + jeonse: "전세", + depositAndMonthly: "전+월세 (보증금有)", + monthlyNoDeposit: "월세 (보증금無)", + otherTenure: "기타", + + // 주거형태 + apartment: "아파트", + house: "주택", + officetel: "오피스텔", + villa: "(연립)빌라", + studio: "원룸", + otherHousingType: "기타", + + // 평형 + under19Pyeong: "19평 이하", + pyeong20s: "20평형 대", + pyeong30s: "30평형 대", + pyeong40s: "40평형 대", + pyeong50Plus: "50평형 대 이상", + + // 권역 + regionCapital: "서울, 인천, 경기도", + regionGyeongnamBusanUlsan: "경남, 부산, 울산", + regionGyeongbukDaegu: "경북, 대구", + regionJeollaGwangju: "전라도, 광주", + regionChungcheongDaejeonSejong: "충청, 대전, 세종", + regionGangwonJeju: "강원, 제주", + + // 소득 + incomeUnder299: "299만원 이하", + income300to599: "300~599만원 이하", + income600to899: "600~899만원 이하", + income900Plus: "900만원 이상", +} as const; export const PRODUCT_KEYS = Object.keys(PRODUCT_KEY_MAP) as Array; export const PRODUCTS = Object.values(PRODUCT_KEY_MAP) as Array; @@ -10,4 +99,56 @@ export const GRID_X_NOT_PADDING = { left: 0, right: 0, top: 50, bottom: 10, cont /** T 축 패딩 없앤 GridOption*/ export const GRID_Y_NOT_PADDING = { left: 10, right: 10, top: 0, bottom: 0, containLabel: false } as const; /** 축 스타일 감춤 */ -export const AXIS_HIDE_STYLE = { axisLabel: { show: false }, axisTick: { show: false }, axisLine: { show: false }} as const; \ No newline at end of file +export const AXIS_HIDE_STYLE = { axisLabel: { show: false }, axisTick: { show: false }, axisLine: { show: false }} as const; + +export const PRODUCTS_FILTER_ITEM = [ + { + path: "ha-kitchen", + items: [ + PRODUCT_KEY_MAP.refrigerator, // 냉장고 + PRODUCT_KEY_MAP.kimchiRefrigerator, // 김치 냉장고 + PRODUCT_KEY_MAP.wineCellar, // 와인 셀러 + PRODUCT_KEY_MAP.dishwasher, // 식기 세척기 + PRODUCT_KEY_MAP.microwave, // 전자 레인지 + PRODUCT_KEY_MAP.airFryer, // 에어 프라이어 + PRODUCT_KEY_MAP.electricRange, // 전기 레인지 + PRODUCT_KEY_MAP.oven, // 오븐 + PRODUCT_KEY_MAP.waterPurifier, // 정수기 + PRODUCT_KEY_MAP.foodWasteDisposer, // 음식물처리기 + ], + }, + { + path: "ha-living", + items: [ + PRODUCT_KEY_MAP.washingMachine, // 세탁기 + PRODUCT_KEY_MAP.dryer, // 건조기 + PRODUCT_KEY_MAP.vacuumCleaner, // 청소기 + PRODUCT_KEY_MAP.robotVacuum, // 로봇 청소기 + PRODUCT_KEY_MAP.massageChair, // 안마 의자 + PRODUCT_KEY_MAP.clothingCareSystem, // 의류 관리기 + PRODUCT_KEY_MAP.shoeCareSystem, // 신발 관리기 + ], + }, + { + path: "air-solution", + items: [ + PRODUCT_KEY_MAP.airConditioner, // 에어컨 + PRODUCT_KEY_MAP.airPurifier, // 공기 청정기 + PRODUCT_KEY_MAP.humidifier, // 가습기 + PRODUCT_KEY_MAP.dehumidifier, // 제습기 + PRODUCT_KEY_MAP.comboAirCareProduct, // 복합 에어케어 제품 + PRODUCT_KEY_MAP.ventilationSystem, // 환기 시스템 + PRODUCT_KEY_MAP.premiumBathroomVentFan // 프리미엄 욕실 환풍기 + ], + }, + { + path: "ms-digital", + items: [ + PRODUCT_KEY_MAP.tv, // TV + PRODUCT_KEY_MAP.monitor, // 모니터 + PRODUCT_KEY_MAP.laptop, // 노트북 + PRODUCT_KEY_MAP.tablet, // 태블릿 + PRODUCT_KEY_MAP.projector, // 빔프로젝터 + ], + }, +] as const; \ No newline at end of file diff --git a/src/types/lg.ts b/src/types/lg.ts new file mode 100644 index 0000000..f0a2cc1 --- /dev/null +++ b/src/types/lg.ts @@ -0,0 +1,33 @@ +import {BANNER_KEY_MAP, PRODUCT_KEY_MAP, PRODUCTS_FILTER_ITEM} from "@/const/lgConst"; + +export type ProductKey = keyof typeof PRODUCT_KEY_MAP; +export type BannerKey = keyof typeof BANNER_KEY_MAP; +export type ProductsFilterItem = (typeof PRODUCTS_FILTER_ITEM)[number]; + + +export type ServerBaseRow = { + year: number; + rowLabel: string; + total: number; +}; + +// { year, rowLabel, total, ...category } +export type ServerProductRow = ServerBaseRow & Partial>; + +// { year, rowLabel, total, ...banner } +// (배너는 기본 41개 키 + 차트별 추가 키가 생길 수 있으니 확장 허용) +export type ServerBannerRow = ServerBaseRow & + Partial> & { + [k: string]: number | string; +}; + +export type LifeStageRow = Record & { + item: string; + total: number | null; + single: number | null; + noKids: number | null; + preschoolKids: number | null; + schoolKids: number | null; + adultKids: number | null; + independentSenior: number | null; +}; \ No newline at end of file