From 84675b77b338d5daed89b874b04e2552798a6885 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Thu, 5 Feb 2026 16:54:55 +0900 Subject: [PATCH] =?UTF-8?q?260205=5F05=5FENH:=201=EC=B0=A8=20lg=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EC=9A=94=EC=B2=AD=EC=82=AC=ED=95=AD=20?= =?UTF-8?q?=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../(main)/total/lg-penetration/page.tsx | 6 +- .../(pages)/(main)/total/lg-purchase/page.tsx | 6 +- .../(pages)/(main)/total/penetration/page.tsx | 4 +- .../(pages)/(main)/total/purchase/page.tsx | 2 +- src/components/layout/CategoryFilter.tsx | 262 +++++++++++------- src/components/layout/Header.tsx | 4 +- src/components/layout/MainLayout.tsx | 119 ++++---- .../lge-dashboard/BannerButtons.tsx | 5 +- .../lge-dashboard/combo/BannerSummary.tsx | 82 +++--- .../lge-dashboard/combo/CategoryByData.tsx | 26 +- .../lge-dashboard/combo/LeftChartTable.tsx | 13 +- .../sub-page/category-page/Brand.tsx | 38 +-- .../sub-page/category-page/OwnershipPath.tsx | 11 +- .../sub-page/category-page/PaymentMethod.tsx | 7 +- .../category-page/PenetrationChange.tsx | 2 +- .../sub-page/category-page/Profile.tsx | 2 +- .../category-page/PurchaseBehavior.tsx | 9 +- .../category-page/PurchaseChannel.tsx | 9 +- .../sub-page/category-page/TypeSpec.tsx | 7 +- .../lge-dashboard/table/DataTable.tsx | 9 +- src/config/sample.data.ts | 74 ++++- src/const/commonConst.ts | 3 +- src/const/lgConst.ts | 63 ++--- src/lib/lg-dashboard.ts | 2 +- src/lib/utils.ts | 3 + 25 files changed, 452 insertions(+), 316 deletions(-) diff --git a/src/app/(pages)/(main)/total/lg-penetration/page.tsx b/src/app/(pages)/(main)/total/lg-penetration/page.tsx index d68151d..47995c9 100644 --- a/src/app/(pages)/(main)/total/lg-penetration/page.tsx +++ b/src/app/(pages)/(main)/total/lg-penetration/page.tsx @@ -13,7 +13,7 @@ import { LIFE_STAGE_GROUPS, PRODUCT_KEY_MAP, PRODUCT_KEYS, - PRODUCTS, + PRODUCTS, SITE_TITLE, YEARS } from "@/const/lgConst"; import {useEffect, useMemo} from "react"; @@ -34,6 +34,8 @@ const LGPenetrationPage = () => { const { filterValue, registerExcelExporter } = useLayoutFilter(); console.log(filterValue); + //TODO: LG가 0인 제품은 제외시키기 + const productTableRows = useMemo(() => { return apiOwnShareOfTotalPenetration.map((row) => ({ label: formatRowLabel(row.rowLabel), @@ -125,7 +127,7 @@ const LGPenetrationPage = () => { ]; await exportDashboardExcel({ - fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(LG제품 보급률).xlsx`, + fileName: `${SITE_TITLE}(LG제품 보급률).xlsx`, sheetName: "LG제품 보급률", sections: sections, }); diff --git a/src/app/(pages)/(main)/total/lg-purchase/page.tsx b/src/app/(pages)/(main)/total/lg-purchase/page.tsx index c09633a..5fde82e 100644 --- a/src/app/(pages)/(main)/total/lg-purchase/page.tsx +++ b/src/app/(pages)/(main)/total/lg-purchase/page.tsx @@ -1,7 +1,7 @@ "use client"; import {useEffect, useMemo} from "react"; -import {LAST_YEAR, PRODUCT_KEY_MAP, PRODUCT_KEYS, PRODUCTS, YEARS} from "@/const/lgConst"; +import {LAST_YEAR, PRODUCT_KEY_MAP, PRODUCT_KEYS, PRODUCTS, SITE_TITLE, YEARS} from "@/const/lgConst"; import { GroupedOverlayBar, type GroupedOverlayBarData, @@ -18,6 +18,8 @@ const LGPurchasePage = () => { const { filterValue, registerExcelExporter } = useLayoutFilter(); console.log(filterValue); + //TODO: LG가 0인 제품은 제외시키기 + const purchaseTableRows = useMemo(() => { return apiOwnShareOfTotalPurchase.map((row) => ({ label: formatRowLabel(row.rowLabel), @@ -68,7 +70,7 @@ const LGPurchasePage = () => { const excelHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP); await exportDashboardExcel({ - fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(LG제품 구매율).xlsx`, + fileName: `${SITE_TITLE}(LG제품 구매율).xlsx`, sheetName: "LG제품 구매율", sections: [ { title: "LG제품 구매율", header: excelHeader, rows: apiOwnShareOfTotalPurchase, rowGap: 1 }, diff --git a/src/app/(pages)/(main)/total/penetration/page.tsx b/src/app/(pages)/(main)/total/penetration/page.tsx index 14a6181..0d3010c 100644 --- a/src/app/(pages)/(main)/total/penetration/page.tsx +++ b/src/app/(pages)/(main)/total/penetration/page.tsx @@ -19,7 +19,7 @@ import { PRODUCTS, YEARS, AXIS_HIDE_STYLE, - GRID_X_NOT_PADDING, PRODUCT_KEY_MAP, LAST_YEAR, + GRID_X_NOT_PADDING, PRODUCT_KEY_MAP, LAST_YEAR, SITE_TITLE, } from "@/const/lgConst"; import { formatRowLabel } from "@/lib/lg-dashboard"; import {buildHeader_ProductKeyMap, exportDashboardExcel, Section} from "@/lib/lg-export-excel"; @@ -89,7 +89,7 @@ const PenetrationPage = () => { ]; await exportDashboardExcel({ - fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(보급률).xlsx`, + fileName: `${SITE_TITLE}(보급률).xlsx`, sheetName: "전체 보급률", sections: sections, }); diff --git a/src/app/(pages)/(main)/total/purchase/page.tsx b/src/app/(pages)/(main)/total/purchase/page.tsx index 0462628..6d34520 100644 --- a/src/app/(pages)/(main)/total/purchase/page.tsx +++ b/src/app/(pages)/(main)/total/purchase/page.tsx @@ -42,7 +42,7 @@ const PurchasePage = () => { const excelHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP); await exportDashboardExcel({ - fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(구매율).xlsx`, + fileName: `${SITE_TITLE}(구매율).xlsx`, sheetName: "구매율", sections: [ { title: "구매율", header: excelHeader, rows: apiTrendBuy, rowGap: 1 }, diff --git a/src/components/layout/CategoryFilter.tsx b/src/components/layout/CategoryFilter.tsx index 3a9ee0c..cb5cc60 100644 --- a/src/components/layout/CategoryFilter.tsx +++ b/src/components/layout/CategoryFilter.tsx @@ -1,12 +1,13 @@ "use client"; -import { CategoryTargetData, CategoryTargetType } from "@/config/filter.types"; +import {CategoryTargetData, CategoryTargetType, TotalFilterItem} from "@/config/filter.types"; import {categoryTarget, categoryTargetType} from "@/config/filter.data"; import { ChevronRight } from "lucide-react"; -import { useMemo } from "react"; +import {useCallback, useMemo} from "react"; import { cn } from "@/lib/utils"; import { Button } from "@/components/ui/button"; import {ProductsFilterItem} from "@/types/lg"; +import {YEARS} from "@/const/lgConst"; export type CategoryTypeValue = { label: string; @@ -15,6 +16,7 @@ export type CategoryTypeValue = { export type CategoryFilterValue = { product: string; + year: string; type: CategoryTypeValue target: CategoryTargetData; }; @@ -26,111 +28,175 @@ type CategoryFilterProps = { className?: string; }; +type Option = { key: string; label: string; value: string | CategoryTypeValue | CategoryTargetData }; + +type RowDef = { + id: "year" | "product" | "type" | "target"; + title: string; + options: Option[]; + isActive: (v: Option["value"]) => boolean; + onSelect: (v: Option["value"]) => void; +}; + +function FilterLine({ title, options, isActive, onSelect }: Omit) { + return ( +
+
+ + + {title} + +
+ +
+
+ {options.map((opt) => { + const active = isActive(opt.value); + return ( + + ); + })} +
+
+
+ ); +} + const CategoryFilter = ({ filterItems, value, onChange, className }: CategoryFilterProps) => { const currentTargetItem = useMemo(() => { return categoryTarget.find((item) => item.type.includes(value.type.value)); - }, [value.type]); + }, [value.type.value]); - const handlePick = ( - key: keyof CategoryFilterValue, - v: string | CategoryTypeValue | CategoryTargetData - ) => { - if (value[key] === v) return; - const next: CategoryFilterValue = { ...value, [key]: v } as CategoryFilterValue; + // type 비교는 객체참조가 아니라 value로 비교해야 함 + const handlePick = useCallback( + (key: keyof CategoryFilterValue, v: string | CategoryTypeValue | CategoryTargetData) => { + // same check + if (key === "type" && typeof v === "object" && "value" in v) { + if (value.type.value === v.value) return; - if (key === "type" && typeof v === "object" && v.value !== value.type.value) { - const nextItem = categoryTarget.find((item) => item.type.includes(v.value)); - const firstTarget = nextItem?.children?.[0]?.target; - if (firstTarget) next.target = firstTarget; - } + const nextItem = categoryTarget.find((item) => item.type.includes(v.value)); + const firstTarget = nextItem?.children?.[0]?.target; - onChange(next); - }; + onChange({ + ...value, + type: v, + target: (firstTarget ?? value.target) as CategoryTargetData, + }); + return; + } + + if (key !== "type") { + // string/primitive 비교 + if ((value as any)[key] === v) return; + onChange({ ...value, [key]: v } as CategoryFilterValue); + } + }, + [value, onChange] + ); + + const rowDefs = useMemo(() => { + const yearRow:RowDef = { + id:"year", + title: "연도", + options:(YEARS).map((y) => ({ + key:y, + label:`20${y}년`, + value:y, + })), + isActive: (v) => value.year === v, + onSelect: (v) => handlePick("year", v as string), + }; + + const productRow: RowDef = { + id: "product", + title: "제품", + options: (filterItems.items ?? []).map((p) => ({ + key: p, + label: p, + value: p, + })), + isActive: (v) => value.product === v, + onSelect: (v) => handlePick("product", v as string), + }; + + const typeRow: RowDef = { + id: "type", + title: "기준", + options: categoryTargetType.map((t) => ({ + key: t.label, + label: t.label, + value: { label: t.label, value: t.value }, + })), + isActive: (v) => { + const vv = v as CategoryTypeValue; + return value.type.value === vv.value; + }, + onSelect: (v) => handlePick("type", v as CategoryTypeValue), + }; + + const targetRow: RowDef = { + id: "target", + title: "데이터", + options: (currentTargetItem?.children ?? []).map((c) => ({ + key: String(c.target), + label: c.label, + value: c.target, + })), + isActive: (v) => value.target === v, + onSelect: (v) => handlePick("target", v as CategoryTargetData), + }; + + // 여기 순서만 바꾸면 배치도 같이 바뀜 (left: 앞쪽 half, right: 뒤쪽 half) + return [yearRow, productRow, typeRow, targetRow]; + }, [YEARS, filterItems.items, currentTargetItem, value, handlePick]); + + const cells = useMemo(() => { + const half = Math.ceil(rowDefs.length / 2); // 3개면 2개(left) + 1개(right) + const maxRows = half; + + return rowDefs.map((def, i) => { + const col = i < half ? 0 : 1; // 0:left, 1:right + const row = i < half ? i : i - half; + + return { def, col, row, maxRows }; + }); + }, [rowDefs]); return (
- {/* 제품 (1줄 나열) */} -
-
- - 제품 -
- -
-
- {filterItems.items.map((p) => { - const active = value.product === p; - return ( - - ); - })} -
-
-
- - {/* 기준 (1줄 나열) */} -
-
- - 기준 -
- -
-
- {categoryTargetType.map((item) => { - const active = value.type.label === item.label; - - return ( - - ); - })} -
-
-
- - {/* 데이터 (1줄 나열) */} -
-
- - 데이터 -
- -
-
- {currentTargetItem?.children?.map((child) => { - const active = value.target === child.target; - return ( - - ); - })} -
-
+
+ {cells.map(({ def, col, row, maxRows }) => { + const showRowDivider = row < maxRows - 1; // 같은 rowIndex 기준으로 좌/우 라인 맞춤 + return ( +
+ +
+ ); + })}
); diff --git a/src/components/layout/Header.tsx b/src/components/layout/Header.tsx index c783fd0..a2784c1 100644 --- a/src/components/layout/Header.tsx +++ b/src/components/layout/Header.tsx @@ -5,8 +5,8 @@ import Image from "next/image"; import {topMenus} from "@/config/menu.data"; import {Button} from "@/components/ui/button"; import {LogOut} from "lucide-react"; -import {DASHBOARD_YEAR} from "@/const/commonConst"; import {cn} from "@/lib/utils"; +import {SITE_TITLE} from "@/const/lgConst"; interface HeaderProps { activeTopId: string; @@ -70,7 +70,7 @@ const Header = ({
-

{DASHBOARD_YEAR}년도 가전보급률 Dashboard

+

{SITE_TITLE}

{/* 우측 컨트롤 */}
diff --git a/src/components/layout/MainLayout.tsx b/src/components/layout/MainLayout.tsx index b213b71..6be7b0f 100644 --- a/src/components/layout/MainLayout.tsx +++ b/src/components/layout/MainLayout.tsx @@ -13,7 +13,7 @@ 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 {LAST_YEAR, PRODUCTS_FILTER_ITEM} from "@/const/lgConst"; import {ProductsFilterItem} from "@/types/lg"; import {ArrowUp} from "lucide-react"; @@ -38,6 +38,7 @@ export const buildDefaultCategoryValue = (categoryFilterItems: ProductsFilterIte const initTarget = firstTarget ?? CategoryTargetData.PROFILE; return { + year: LAST_YEAR, product: initProduct, type: initType, target: initTarget, @@ -118,73 +119,79 @@ const MainLayout = ({ children }: MainLayoutProps) => { -
-
- -
-
-
- - - -
- - {isFilterOpen && ( -
- {isTotal ? ( - - ) : ( - - )} -
- )} - -
-
-
- {children} -
-
- - {showScrollTop && ( +
+ +
+
+
+
+ {isTotal && ( +
+ 페이지에 대한 설명 +
+ )} +
+ +
+ + {isFilterOpen && ( +
+ {isTotal ? ( + + ) : ( + + )} +
)} + +
+
+
+ {children} +
+
+ + {showScrollTop && ( + + )} +
-
); diff --git a/src/components/lge-dashboard/BannerButtons.tsx b/src/components/lge-dashboard/BannerButtons.tsx index 74362ca..1fca216 100644 --- a/src/components/lge-dashboard/BannerButtons.tsx +++ b/src/components/lge-dashboard/BannerButtons.tsx @@ -14,13 +14,14 @@ const BannerButtons = ({ onSelectBanner }: BannerButtonsProps) => { return ( -
+
+
구분 필터
{banners.map((banner) => (
+
{SAMPLE_SIZE_NOTICE}
); }; diff --git a/src/components/lge-dashboard/combo/LeftChartTable.tsx b/src/components/lge-dashboard/combo/LeftChartTable.tsx index 51dd024..c84a958 100644 --- a/src/components/lge-dashboard/combo/LeftChartTable.tsx +++ b/src/components/lge-dashboard/combo/LeftChartTable.tsx @@ -5,6 +5,7 @@ import { cn, parseNumber } from "@/lib/utils"; import type { DataColumn, SignStyle } from "../types"; import SectionTitle from "../SectionTitle"; import { TABLE_DIMENSIONS } from "@/const/chartConst"; +import {isSampleRow} from "@/lib/lg-dashboard"; type MergedChartCell = { /** 차트를 삽입할 컬럼 key(해당 컬럼 td는 startRow에서만 렌더되고 rowSpan 적용) */ @@ -32,6 +33,7 @@ type Props> = { wrapperClassName?: string; tableClassName?: string; minWidthPx?: number; + starUnder30Sample?: boolean; }; // toNumber는 utils.ts의 parseNumber로 통합됨 @@ -65,6 +67,7 @@ export default function LeftChartTable>({ wrapperClassName, tableClassName, minWidthPx = TABLE_DIMENSIONS.MIN_WIDTH.COMPACT, + starUnder30Sample = true }: Props) { const hasGroupHeader = useMemo( () => columns.some((c) => c.group) || columns.some((c) => c.headRowSpan === 2), @@ -169,6 +172,7 @@ export default function LeftChartTable>({ {rows.map((row, ri) => { + const sampleRow = isSampleRow(row.rowLabel as string ?? ""); const isSignRow = signStyle?.rowSelector ? signStyle.rowSelector(row, ri) : false; return ( @@ -199,7 +203,7 @@ export default function LeftChartTable>({ ? raw : String(raw); - const n = isSignRow ? parseNumber(raw) : null; + const n = c.numeric ? parseNumber(raw) : null; const shouldSign = isSignRow && (signStyle?.keys ? signStyle.keys.includes(c.key) : !!c.numeric); if (c.rowHead) { @@ -216,13 +220,16 @@ export default function LeftChartTable>({ } if (!shouldSign) { + const numContent = c.numeric ? parseNumber(content) ?? 0 : 0; + const isStar = starUnder30Sample && sampleRow && numContent < 30; + return ( - {content} + {isStar?`${content}*`:content} ); } @@ -236,8 +243,10 @@ export default function LeftChartTable>({ ); } + const cls = n > 0 ? posCls : n < 0 ? negCls : zeroCls; const txt = renderSigned(n, { display, showPlus, arrowWithNumber, zeroText }); + return ( {txt} diff --git a/src/components/lge-dashboard/sub-page/category-page/Brand.tsx b/src/components/lge-dashboard/sub-page/category-page/Brand.tsx index 3fe11d5..ea5eede 100644 --- a/src/components/lge-dashboard/sub-page/category-page/Brand.tsx +++ b/src/components/lge-dashboard/sub-page/category-page/Brand.tsx @@ -5,44 +5,17 @@ import {CategoryByData} from "@/components/lge-dashboard"; import {apiBrandShareByYear} from "@/config/sample.data"; import {PageData, ServerBannerRow} from "@/types/lg"; import {buildGapRow} from "@/lib/lg-dashboard"; -import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR, YEARS} from "@/const/lgConst"; +import {BANNER_GROUP, BANNER_KEY_MAP, SITE_TITLE, YEARS} from "@/const/lgConst"; import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; import {CategoryTypeValue} from "@/components/layout/CategoryFilter"; import {buildHeader_Banner, exportDashboardExcel, Section} from "@/lib/lg-export-excel"; const Brand = () => { const {filterValue, registerExcelExporter} = useLayoutFilter(); - const tableDataArray = useMemo[]>(() => { - const cleaned = apiBrandShareByYear.filter( - (r) => !(r.year === LAST_YEAR && r.rowLabel === "gap") - ); - const gapRow = buildGapRow(cleaned, 25, 26, "lg", "gap"); - - let finalData = cleaned; - - if (gapRow) { - const insertIdx = cleaned.findIndex( - (r) => r.year === LAST_YEAR && r.rowLabel === "lg" - ); - - if (insertIdx >= 0) { - finalData = [ - ...cleaned.slice(0, insertIdx + 1), - gapRow, - ...cleaned.slice(insertIdx + 1), - ]; - } - } - - return [ - { - title: "브랜드", - chartMode: "reverseStack", - data: finalData, - }, - ]; - }, []); + const tableDataArray = useMemo[]>(() => [ + {title: "브랜드", chartMode:"reverseStack", data: apiBrandShareByYear}, + ], []); useEffect(() => { registerExcelExporter(async (payload) => { @@ -63,7 +36,7 @@ const Brand = () => { }); await exportDashboardExcel({ - fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`, + fileName: `${SITE_TITLE}(${sheetName}).xlsx`, sheetName: sheetName, sections: sections, }); @@ -76,6 +49,7 @@ const Brand = () => { {tableDataArray.map((tableData) => ( { console.log(filterValue); const tableDataArray = useMemo[]>(() => [ - {title: "보유 경로", chartMode:"reverseStack", data: apiOwnershipPathByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap"))}, - {title: "구입 계기", chartMode:"horizontal", data: apiOwnershipTriggerByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap"))}, + {title: "보유 경로", chartMode:"reverseStack", data: apiOwnershipPathByYear}, + {title: "구입 계기", chartMode:"horizontal", data: apiOwnershipTriggerByYear, chartHeight: 550,}, ], []); useEffect(() => { @@ -37,7 +37,7 @@ const OwnershipPath = () => { }); await exportDashboardExcel({ - fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`, + fileName: `${SITE_TITLE}(${sheetName}).xlsx`, sheetName: sheetName, sections: sections, }); @@ -50,6 +50,7 @@ const OwnershipPath = () => { {tableDataArray.map((tableData) => ( { console.log(filterValue); const tableDataArray = useMemo[]>(() => [ - {title: "구매 형식", chartMode:"reverseStack", data: apiPaymentMethodByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap"))}, + {title: "구매 형식", chartMode:"reverseStack", data: apiPaymentMethodByYear}, ], []); useEffect(() => { @@ -36,7 +36,7 @@ const PaymentMethod = () => { }); await exportDashboardExcel({ - fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`, + fileName: `${SITE_TITLE}(${sheetName}).xlsx`, sheetName: sheetName, sections: sections, }); @@ -49,6 +49,7 @@ const PaymentMethod = () => { {tableDataArray.map((tableData) => ( { const penetrationChangeData = useMemo(() => apiYearIndex, []); return( - + ); } diff --git a/src/components/lge-dashboard/sub-page/category-page/Profile.tsx b/src/components/lge-dashboard/sub-page/category-page/Profile.tsx index 1dbc804..4520f16 100644 --- a/src/components/lge-dashboard/sub-page/category-page/Profile.tsx +++ b/src/components/lge-dashboard/sub-page/category-page/Profile.tsx @@ -27,7 +27,7 @@ const Profile = () => { }, [isTotal, filterValue]); return ( - + ); } diff --git a/src/components/lge-dashboard/sub-page/category-page/PurchaseBehavior.tsx b/src/components/lge-dashboard/sub-page/category-page/PurchaseBehavior.tsx index 0911995..c47542b 100644 --- a/src/components/lge-dashboard/sub-page/category-page/PurchaseBehavior.tsx +++ b/src/components/lge-dashboard/sub-page/category-page/PurchaseBehavior.tsx @@ -5,7 +5,7 @@ import {useEffect, useMemo} from "react"; import {PageData, ServerBannerRow} from "@/types/lg"; import { apiOwnershipPathByYear, apiOwnershipTriggerByYear} from "@/config/sample.data"; import {CategoryByData} from "@/components/lge-dashboard"; -import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR, YEARS} from "@/const/lgConst"; +import {BANNER_GROUP, BANNER_KEY_MAP, SITE_TITLE, YEARS} from "@/const/lgConst"; import {CategoryTypeValue} from "@/components/layout/CategoryFilter"; import {buildHeader_Banner, exportDashboardExcel, Section} from "@/lib/lg-export-excel"; @@ -14,8 +14,8 @@ const PurchaseBehavior = () => { console.log(filterValue); const tableDataArray = useMemo[]>(() => [ - {title: "보유 경로", chartMode:"horizontal", data: apiOwnershipPathByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap"))}, - {title: "구입 계기", chartMode:"horizontal", data: apiOwnershipTriggerByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap"))}, + {title: "보유 경로", chartMode:"horizontal", data: apiOwnershipPathByYear}, + {title: "구입 계기", chartMode:"horizontal", data: apiOwnershipTriggerByYear}, ], []); useEffect(() => { @@ -37,7 +37,7 @@ const PurchaseBehavior = () => { }); await exportDashboardExcel({ - fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`, + fileName: `${SITE_TITLE}(${sheetName}).xlsx`, sheetName: sheetName, sections: sections, }); @@ -50,6 +50,7 @@ const PurchaseBehavior = () => { {tableDataArray.map((tableData) => ( { { title: "구매 채널(온/오프라인)", chartMode: "reverseStack", - data: apiPurchaseChannelSummaryByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap")), + data: apiPurchaseChannelSummaryByYear, }, { title: "구매 채널(상세)", chartMode: "horizontal", - data: apiPurchaseChannelByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap")), + data: apiPurchaseChannelByYear, chartHeight: 550, }, ], []); @@ -49,7 +49,7 @@ const PurchaseChannel = () => { }); await exportDashboardExcel({ - fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`, + fileName: `${SITE_TITLE}(${sheetName}).xlsx`, sheetName: sheetName, sections: sections, }); @@ -62,6 +62,7 @@ const PurchaseChannel = () => { {tableDataArray.map((tableData) => ( { { title: "타입", chartMode: "horizontal", - data: apiFridgeDoorTypeByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap")), + data: apiFridgeDoorTypeByYear, }, ], []); @@ -40,7 +40,7 @@ const TypeSpec = () => { }); await exportDashboardExcel({ - fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`, + fileName: `${SITE_TITLE}(${sheetName}).xlsx`, sheetName: sheetName, sections: sections, }); @@ -53,6 +53,7 @@ const TypeSpec = () => { {tableDataArray.map((tableData) => ( > = { columns: DataColumn[]; @@ -14,6 +15,7 @@ type Props> = { wrapperClassName?: string; signStyle?: SignStyle; fillGreaterThan5?: boolean; + starUnder30Sample?: boolean; }; // parseSignedNumber는 utils.ts의 parseNumber로 통합됨 @@ -55,6 +57,7 @@ const DataTable = >({ wrapperClassName, signStyle, fillGreaterThan5 = false, + starUnder30Sample = false, }: Props) => { const hasGroup = columns.some((c) => !!c.group) || columns.some((c) => c.headRowSpan === 2); @@ -177,6 +180,7 @@ const DataTable = >({ {rows.map((row, rIdx) => { + const sampleRow = isSampleRow(row.rowLabel as string ?? ""); const signRow = isSignRow(row, rIdx); const total = parseNumber(row.total); @@ -227,14 +231,15 @@ const DataTable = >({ ); } - const numContent = c.numeric ? parseNumber(content) ?? 0 : 0; const isFill = fillGreaterThan5 && total && numContent > total + 5; + const isStar = starUnder30Sample && sampleRow && numContent < 30; + return ( - {content} + {isStar?`${content}*`:content} ); })} diff --git a/src/config/sample.data.ts b/src/config/sample.data.ts index ebfa47f..15daf20 100644 --- a/src/config/sample.data.ts +++ b/src/config/sample.data.ts @@ -290,8 +290,18 @@ export const apiLifeStageByProduct: ServerBannerRow[] = [ export const apiOwnershipSummary: ServerBannerRow[] = [ bannerRow("26", "사례수", "2000"), bannerRow("26", "보유율", "85"), - bannerRow("26", "gap", "1"), // 26-25 - bannerRow("26", "보유대수", "1.2"), + bannerRow("26", "gap", "5"), // 26-25 + bannerRow("26", "보유대수", "1.3"), + + bannerRow("25", "사례수", "2000"), + bannerRow("25", "보유율", "80"), + bannerRow("25", "gap", "4"), // 26-25 + bannerRow("25", "보유대수", "1.2"), + + bannerRow("24", "사례수", "2000"), + bannerRow("24", "보유율", "76"), + bannerRow("24", "gap", "-", ), // 26-25 + bannerRow("24", "보유대수", "1.0"), ]; /** --------------------------- @@ -315,8 +325,18 @@ export const apiYearIndex: ServerBannerRow[] = [ * 25/26 사례수 + 브랜드 * -------------------------- */ export const apiBrandShareByYear: ServerBannerRow[] = [ + bannerRow("24", "사례수", "500"), + bannerRow("24", "lg", "46"), + bannerRow("24", "gap", "-"), + bannerRow("24", "삼성", "41"), + bannerRow("24", "위니아", "4"), + bannerRow("24", "캐리어", "4"), + bannerRow("24", "하이얼", "1"), + bannerRow("24", "기타", "4"), + bannerRow("25", "사례수", "500"), bannerRow("25", "lg", "48"), + bannerRow("25", "gap", "2"), bannerRow("25", "삼성", "40"), bannerRow("25", "위니아", "4"), bannerRow("25", "캐리어", "3"), @@ -325,6 +345,7 @@ export const apiBrandShareByYear: ServerBannerRow[] = [ bannerRow("26", "사례수", "520"), bannerRow("26", "lg", "47"), + bannerRow("26", "gap", "-1"), bannerRow("26", "삼성", "40"), bannerRow("26", "위니아", "5"), bannerRow("26", "캐리어", "3"), @@ -361,6 +382,12 @@ export const apiFridgeDoorTypeByYear: ServerBannerRow[] = [ * 25/26 사례수 + 보유 경로(구매 경로) * -------------------------- */ export const apiOwnershipPathByYear: ServerBannerRow[] = [ + bannerRow("24", "사례수", "520"), + bannerRow("24", "신규 구입", "7"), + bannerRow("24", "기존 제품 작동하나 신규 구입", "5"), + bannerRow("24", "기존 제품 고장으로 신규 구입", "30"), + bannerRow("24", "추가 구입", "58"), + bannerRow("25", "사례수", "520"), bannerRow("25", "신규 구입", "8"), bannerRow("25", "기존 제품 작동하나 신규 구입", "4"), @@ -375,6 +402,17 @@ export const apiOwnershipPathByYear: ServerBannerRow[] = [ ]; export const apiOwnershipTriggerByYear: ServerBannerRow[] = [ + bannerRow("24", "사례수", "520"), + bannerRow("24", "오래되어 새로운 제품 교체 필요", "23"), + bannerRow("24", "이사로 인해 새로 구입", "22"), + bannerRow("24", "이전 제품 고장으로 새로 구입", "17"), + bannerRow("24", "새로운 기능/기술 사용하고 싶어서", "14"), + bannerRow("24", "리모델링, 인테리어 계기로 새로 구입", "7"), + bannerRow("24", "혼수로 장만", "7"), + bannerRow("24", "(결혼 외) 가구 분가/독립하게 되어서", "6"), + bannerRow("24", "가구 구성원이 늘어서", "3"), + bannerRow("24", "가구 구성원이 줄어서", '2'), + bannerRow("25", "사례수", "520"), bannerRow("25", "오래되어 새로운 제품 교체 필요", "23"), bannerRow("25", "이사로 인해 새로 구입", "22"), @@ -404,6 +442,11 @@ export const apiOwnershipTriggerByYear: ServerBannerRow[] = [ * 25/26 결제수단 * -------------------------- */ export const apiPaymentMethodByYear: ServerBannerRow[] = [ + bannerRow("24", "사례수", "650"), + bannerRow("24", "일시불", "60"), + bannerRow("24", "할부", "30"), + bannerRow("24", "렌탈", "10"), + bannerRow("25", "사례수", "650"), bannerRow("25", "일시불", "60"), bannerRow("25", "할부", "30"), @@ -424,9 +467,21 @@ export const apiPurchaseRateKpis: ServerBannerRow[] = [ bannerRow("26", "사례수", "700"), bannerRow("26", "구매율", "35"), bannerRow("26", "gap", "2"), // 26-25 + + bannerRow("25", "사례수", "700"), + bannerRow("25", "구매율", "33"), + bannerRow("25", "gap", "5"), // 26-25 + + bannerRow("24", "사례수", "700"), + bannerRow("24", "구매율", "28"), + bannerRow("24", "gap", "-"), // 26-25 ]; export const apiPurchaseChannelSummaryByYear: ServerBannerRow[] = [ + bannerRow("24", "사례수", "650"), + bannerRow("24", "오프라인", "65"), + bannerRow("24", "온라인/홈쇼핑", "35"), + bannerRow("25", "사례수", "650"), bannerRow("25", "오프라인", "60"), bannerRow("25", "온라인/홈쇼핑", "40"), @@ -442,6 +497,21 @@ export const apiPurchaseChannelSummaryByYear: ServerBannerRow[] = [ * 25/26 사례수 + 유통채널 * -------------------------- */ export const apiPurchaseChannelByYear: ServerBannerRow[] = [ + bannerRow("24", "사례수", "650"), + bannerRow("24", "오프라인 단독 매장", "25"), + bannerRow("24", "전자제품 양판점", "20"), + bannerRow("24", "대형할인점", "10"), + bannerRow("24", "백화점", "5"), + bannerRow("24", "오픈마켓", "15"), + bannerRow("24", "제조사 공식 홈페이지", "8"), + bannerRow("24", "포털 쇼핑채널 입점몰", "4"), + bannerRow("24", "백화점 기반 쇼핑몰", "2"), + bannerRow("24", "TV 홈쇼핑", "3"), + bannerRow("24", "유통사 온라인 쇼핑몰", "4"), + bannerRow("24", "라이프스타일 쇼핑몰", "2"), + bannerRow("24", "해외 직구/대행 사이트", "1"), + bannerRow("24", "중고거래 사이트", "1"), + bannerRow("25", "사례수", "650"), bannerRow("25", "오프라인 단독 매장", "25"), bannerRow("25", "전자제품 양판점", "20"), diff --git a/src/const/commonConst.ts b/src/const/commonConst.ts index f43a29f..85df5ce 100644 --- a/src/const/commonConst.ts +++ b/src/const/commonConst.ts @@ -1,3 +1,2 @@ export const UNKNOWN_HTTP_ERROR = 'UNKNOWN_HTTP_ERROR'; -export const NONE_HTTP_ERROR = 'NONE_HTTP_ERROR'; -export const DASHBOARD_YEAR = 2026; \ No newline at end of file +export const NONE_HTTP_ERROR = 'NONE_HTTP_ERROR'; \ No newline at end of file diff --git a/src/const/lgConst.ts b/src/const/lgConst.ts index ad88c1b..97ffbce 100644 --- a/src/const/lgConst.ts +++ b/src/const/lgConst.ts @@ -1,36 +1,28 @@ import {BannerKey, LifeStageRow} from "@/types/lg"; import {GaugeColumn} from "@/components/lge-dashboard"; +export const SITE_TITLE = 'LGE CX 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: "의류 관리기", + waterPurifier: "정수기", + electricRange: "전기 레인지", foodWasteDisposer: "음식물처리기", - projector: "빔프로젝터", - comboAirCareProduct: "복합 에어케어 제품", - ventilationSystem: "환기 시스템", - wineCellar: "와인 셀러", - premiumBathroomVentFan: "프리미엄 욕실 환풍기", - shoeCareSystem: "신발 관리기", + + washingMachine: "세탁기", + dryer: "건조기", + vacuumCleaner: "청소기", + robotVacuum: "로봇 청소기", + clothingCareSystem: "의류 관리기", + + airConditioner: "에어컨", + airPurifier: "공기 청정기", + + tv: "TV", + monitor: "모니터", + laptop: "노트북", } as const; export const BANNER_KEY_MAP = { @@ -115,7 +107,7 @@ export const LIFE_STAGE_GROUPS = [ export const PRODUCT_KEYS = Object.keys(PRODUCT_KEY_MAP) as Array; export const PRODUCTS = Object.values(PRODUCT_KEY_MAP) as Array; export const YEARS = ["24", "25", "26"]; -export const LAST_YEAR = YEARS.at(-1); +export const LAST_YEAR = YEARS.at(-1)!; export const BRAND_LIST = ['Cbrand', 'Samsung', 'LG']; /** X 축 패딩 없앤 GridOption*/ @@ -132,12 +124,8 @@ export const PRODUCTS_FILTER_ITEM = [ PRODUCT_KEY_MAP.refrigerator, // 냉장고 PRODUCT_KEY_MAP.kimchiRefrigerator, // 김치 냉장고 PRODUCT_KEY_MAP.dishwasher, // 식기 세척기 - - PRODUCT_KEY_MAP.microwave, // 전자 레인지 - - PRODUCT_KEY_MAP.electricRange, // 전기 레인지 - PRODUCT_KEY_MAP.oven, // 오븐 PRODUCT_KEY_MAP.waterPurifier, // 정수기 + PRODUCT_KEY_MAP.electricRange, // 전기 레인지 PRODUCT_KEY_MAP.foodWasteDisposer, // 음식물처리기 ], }, @@ -149,8 +137,6 @@ export const PRODUCTS_FILTER_ITEM = [ PRODUCT_KEY_MAP.vacuumCleaner, // 청소기 PRODUCT_KEY_MAP.robotVacuum, // 로봇 청소기 PRODUCT_KEY_MAP.clothingCareSystem, // 의류 관리기 - PRODUCT_KEY_MAP.massageChair, // 안마 의자 - PRODUCT_KEY_MAP.shoeCareSystem, // 신발 관리기 ], }, { @@ -158,11 +144,6 @@ export const PRODUCTS_FILTER_ITEM = [ 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 // 프리미엄 욕실 환풍기 ], }, { @@ -171,8 +152,6 @@ export const PRODUCTS_FILTER_ITEM = [ PRODUCT_KEY_MAP.tv, // TV PRODUCT_KEY_MAP.monitor, // 모니터 PRODUCT_KEY_MAP.laptop, // 노트북 - PRODUCT_KEY_MAP.tablet, // 태블릿 - PRODUCT_KEY_MAP.projector, // 빔프로젝터 ], }, ] as const; @@ -229,4 +208,6 @@ export const BANNER_GROUP = { label: "소득수준", keys: [BANNER_KEY.incomeUnder299, BANNER_KEY.income300to599, BANNER_KEY.income600to899, BANNER_KEY.income900Plus], }, -} as const; \ No newline at end of file +} as const; + +export const SAMPLE_SIZE_NOTICE = "* 30 미만 샘플에 대한 설명"; \ No newline at end of file diff --git a/src/lib/lg-dashboard.ts b/src/lib/lg-dashboard.ts index b3284f2..9d6ea99 100644 --- a/src/lib/lg-dashboard.ts +++ b/src/lib/lg-dashboard.ts @@ -3,7 +3,7 @@ import {ChartData} from "@/components/lge-dashboard"; import {BANNER_GROUP} from "@/const/lgConst"; import {formatNumber} from "@/lib/utils"; -export const isSampleRow = (raw: string) => raw.replace(/\s+/g, "") === "사례수"; +export const isSampleRow = (raw: string) => raw.replace(/\s+/g, "").includes("사례수"); /** * Row Label을 표시용 텍스트로 포맷팅합니다. diff --git a/src/lib/utils.ts b/src/lib/utils.ts index baa1b54..95e2774 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -133,6 +133,9 @@ export function parseNumber( if (s === "" || s === "-" || s === "−") return null; + s = s.replaceAll("(", ""); + s = s.replaceAll(")", ""); + if (allowComma) s = s.replaceAll(",", ""); if (allowPercent) s = s.replaceAll("%", ""); if (allowMinus) s = s.replaceAll("−", "-"); // 유니코드 마이너스 -> ASCII 마이너스