260205_01_ENH: 페이지 별 엑셀 다운로드 적용
This commit is contained in:
@@ -1,18 +1,20 @@
|
||||
'use client'
|
||||
|
||||
import {useMemo} from "react";
|
||||
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
|
||||
import {useEffect, useMemo} from "react";
|
||||
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 {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 } = useLayoutFilter();
|
||||
|
||||
const {filterValue, registerExcelExporter} = useLayoutFilter();
|
||||
const tableDataArray = useMemo<PageData<ServerBannerRow>[]>(() => {
|
||||
const cleaned = apiBrandShareByYear.filter(
|
||||
(r) => !(r.year === 26 && r.rowLabel === "gap")
|
||||
(r) => !(r.year === LAST_YEAR && r.rowLabel === "gap")
|
||||
);
|
||||
|
||||
const gapRow = buildGapRow(cleaned, 25, 26, "lg", "gap");
|
||||
@@ -21,7 +23,7 @@ const Brand = () => {
|
||||
|
||||
if (gapRow) {
|
||||
const insertIdx = cleaned.findIndex(
|
||||
(r) => r.year === 26 && r.rowLabel === "lg"
|
||||
(r) => r.year === LAST_YEAR && r.rowLabel === "lg"
|
||||
);
|
||||
|
||||
if (insertIdx >= 0) {
|
||||
@@ -42,6 +44,33 @@ const Brand = () => {
|
||||
];
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
registerExcelExporter(async (payload) => {
|
||||
|
||||
const sheetName = `${filterValue.product}_${(filterValue.type as CategoryTypeValue).label}_브랜드`
|
||||
const h3 = buildHeader_Banner(BANNER_GROUP, BANNER_KEY_MAP);
|
||||
|
||||
type AnyRow = Record<string, any>;
|
||||
const sections: Section<AnyRow>[] = tableDataArray.flatMap((tableData) => {
|
||||
const years = [YEARS.at(-1), YEARS.at(-2)];
|
||||
|
||||
return years.map((year) => ({
|
||||
title: `${tableData.title}_${year}년`,
|
||||
header: h3,
|
||||
rows: tableData.data.filter((d) => d.year === year) as AnyRow[],
|
||||
rowGap: 1,
|
||||
}));
|
||||
});
|
||||
|
||||
await exportDashboardExcel({
|
||||
fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`,
|
||||
sheetName: sheetName,
|
||||
sections: sections,
|
||||
});
|
||||
});
|
||||
return () => registerExcelExporter(null);
|
||||
}, [registerExcelExporter]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
{tableDataArray.map((tableData) => (
|
||||
|
||||
@@ -1,20 +1,50 @@
|
||||
'use client'
|
||||
|
||||
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
|
||||
import {useMemo} from "react";
|
||||
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 {CategoryTypeValue} from "@/components/layout/CategoryFilter";
|
||||
import {buildHeader_Banner, exportDashboardExcel, Section} from "@/lib/lg-export-excel";
|
||||
|
||||
const OwnershipPath = () => {
|
||||
const { filterValue } = useLayoutFilter();
|
||||
const { filterValue, registerExcelExporter } = useLayoutFilter();
|
||||
console.log(filterValue);
|
||||
|
||||
const tableDataArray = useMemo<PageData<ServerBannerRow>[]>(() => [
|
||||
{title: "보유 경로", chartMode:"reverseStack", data: apiOwnershipPathByYear.filter(r => !(r.year === 26 && r.rowLabel === "gap"))},
|
||||
{title: "구입 계기", chartMode:"horizontal", data: apiOwnershipTriggerByYear.filter(r => !(r.year === 26 && r.rowLabel === "gap"))},
|
||||
{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"))},
|
||||
], []);
|
||||
|
||||
useEffect(() => {
|
||||
registerExcelExporter(async (payload) => {
|
||||
|
||||
const sheetName = `${filterValue.product}_${(filterValue.type as CategoryTypeValue).label}_보유 경로`
|
||||
const h3 = buildHeader_Banner(BANNER_GROUP, BANNER_KEY_MAP);
|
||||
|
||||
type AnyRow = Record<string, any>;
|
||||
const sections: Section<AnyRow>[] = tableDataArray.flatMap((tableData) => {
|
||||
const years = [YEARS.at(-1), YEARS.at(-2)];
|
||||
|
||||
return years.map((year) => ({
|
||||
title: `${tableData.title}_${year}년`,
|
||||
header: h3,
|
||||
rows: tableData.data.filter((d) => d.year === year) as AnyRow[],
|
||||
rowGap: 1,
|
||||
}));
|
||||
});
|
||||
|
||||
await exportDashboardExcel({
|
||||
fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`,
|
||||
sheetName: sheetName,
|
||||
sections: sections,
|
||||
});
|
||||
});
|
||||
return () => registerExcelExporter(null);
|
||||
}, [registerExcelExporter]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
{tableDataArray.map((tableData) => (
|
||||
|
||||
@@ -1,19 +1,49 @@
|
||||
'use client'
|
||||
|
||||
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
|
||||
import {apiOwnershipPathByYear, apiOwnershipTriggerByYear, apiPaymentMethodByYear} from "@/config/sample.data";
|
||||
import {useMemo} from "react";
|
||||
import {apiPaymentMethodByYear} from "@/config/sample.data";
|
||||
import {useEffect, useMemo} from "react";
|
||||
import {PageData, ServerBannerRow} from "@/types/lg";
|
||||
import {CategoryByData} from "@/components/lge-dashboard";
|
||||
import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR, YEARS} from "@/const/lgConst";
|
||||
import {CategoryTypeValue} from "@/components/layout/CategoryFilter";
|
||||
import {buildHeader_Banner, exportDashboardExcel, Section} from "@/lib/lg-export-excel";
|
||||
|
||||
const PaymentMethod = () => {
|
||||
const { filterValue } = useLayoutFilter();
|
||||
const { filterValue, registerExcelExporter } = useLayoutFilter();
|
||||
console.log(filterValue);
|
||||
|
||||
const tableDataArray = useMemo<PageData<ServerBannerRow>[]>(() => [
|
||||
{title: "구매 형식", chartMode:"reverseStack", data: apiPaymentMethodByYear.filter(r => !(r.year === 26 && r.rowLabel === "gap"))},
|
||||
{title: "구매 형식", chartMode:"reverseStack", data: apiPaymentMethodByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap"))},
|
||||
], []);
|
||||
|
||||
useEffect(() => {
|
||||
registerExcelExporter(async (payload) => {
|
||||
|
||||
const sheetName = `${filterValue.product}_${(filterValue.type as CategoryTypeValue).label}_구매 형식`
|
||||
const h3 = buildHeader_Banner(BANNER_GROUP, BANNER_KEY_MAP);
|
||||
|
||||
type AnyRow = Record<string, any>;
|
||||
const sections: Section<AnyRow>[] = tableDataArray.flatMap((tableData) => {
|
||||
const years = [YEARS.at(-1), YEARS.at(-2)];
|
||||
|
||||
return years.map((year) => ({
|
||||
title: `${tableData.title}_${year}년`,
|
||||
header: h3,
|
||||
rows: tableData.data.filter((d) => d.year === year) as AnyRow[],
|
||||
rowGap: 1,
|
||||
}));
|
||||
});
|
||||
|
||||
await exportDashboardExcel({
|
||||
fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`,
|
||||
sheetName: sheetName,
|
||||
sections: sections,
|
||||
});
|
||||
});
|
||||
return () => registerExcelExporter(null);
|
||||
}, [registerExcelExporter]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
{tableDataArray.map((tableData) => (
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
|
||||
import BannerSummary from "@/components/lge-dashboard/combo/BannerSummary";
|
||||
import { useMemo } from "react";
|
||||
import {useMemo} from "react";
|
||||
import {ServerBannerRow} from "@/types/lg";
|
||||
import {apiOwnershipSummary, apiPurchaseRateKpis} from "@/config/sample.data";
|
||||
|
||||
|
||||
@@ -1,20 +1,50 @@
|
||||
'use client'
|
||||
|
||||
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
|
||||
import {useMemo} from "react";
|
||||
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 {CategoryTypeValue} from "@/components/layout/CategoryFilter";
|
||||
import {buildHeader_Banner, exportDashboardExcel, Section} from "@/lib/lg-export-excel";
|
||||
|
||||
const PurchaseBehavior = () => {
|
||||
const { filterValue } = useLayoutFilter();
|
||||
const { filterValue, registerExcelExporter } = useLayoutFilter();
|
||||
console.log(filterValue);
|
||||
|
||||
const tableDataArray = useMemo<PageData<ServerBannerRow>[]>(() => [
|
||||
{title: "보유 경로", chartMode:"horizontal", data: apiOwnershipPathByYear.filter(r => !(r.year === 26 && r.rowLabel === "gap"))},
|
||||
{title: "구입 계기", chartMode:"horizontal", data: apiOwnershipTriggerByYear.filter(r => !(r.year === 26 && r.rowLabel === "gap"))},
|
||||
{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"))},
|
||||
], []);
|
||||
|
||||
useEffect(() => {
|
||||
registerExcelExporter(async (payload) => {
|
||||
|
||||
const sheetName = `${filterValue.product}_${(filterValue.type as CategoryTypeValue).label}_구입 행태`
|
||||
const h3 = buildHeader_Banner(BANNER_GROUP, BANNER_KEY_MAP);
|
||||
|
||||
type AnyRow = Record<string, any>;
|
||||
const sections: Section<AnyRow>[] = tableDataArray.flatMap((tableData) => {
|
||||
const years = [YEARS.at(-1), YEARS.at(-2)];
|
||||
|
||||
return years.map((year) => ({
|
||||
title: `${tableData.title}_${year}년`,
|
||||
header: h3,
|
||||
rows: tableData.data.filter((d) => d.year === year) as AnyRow[],
|
||||
rowGap: 1,
|
||||
}));
|
||||
});
|
||||
|
||||
await exportDashboardExcel({
|
||||
fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`,
|
||||
sheetName: sheetName,
|
||||
sections: sections,
|
||||
});
|
||||
});
|
||||
return () => registerExcelExporter(null);
|
||||
}, [registerExcelExporter]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
{tableDataArray.map((tableData) => (
|
||||
|
||||
@@ -2,33 +2,61 @@
|
||||
|
||||
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
|
||||
import {
|
||||
apiOwnershipPathByYear,
|
||||
apiOwnershipTriggerByYear,
|
||||
apiPurchaseChannelByYear,
|
||||
apiPurchaseChannelSummaryByYear
|
||||
} from "@/config/sample.data";
|
||||
import {useMemo} from "react";
|
||||
import {useEffect, useMemo} from "react";
|
||||
import {PageData, ServerBannerRow} from "@/types/lg";
|
||||
import {CategoryByData} from "@/components/lge-dashboard";
|
||||
import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR, YEARS} from "@/const/lgConst";
|
||||
import {CategoryTypeValue} from "@/components/layout/CategoryFilter";
|
||||
import {buildHeader_Banner, exportDashboardExcel, Section} from "@/lib/lg-export-excel";
|
||||
|
||||
const PurchaseChannel = () => {
|
||||
const { filterValue } = useLayoutFilter();
|
||||
const { filterValue, registerExcelExporter } = useLayoutFilter();
|
||||
console.log(filterValue);
|
||||
|
||||
const tableDataArray = useMemo<PageData<ServerBannerRow>[]>(() => [
|
||||
{
|
||||
title: "구매 채널(온/오프라인)",
|
||||
chartMode: "reverseStack",
|
||||
data: apiPurchaseChannelSummaryByYear.filter(r => !(r.year === 26 && r.rowLabel === "gap")),
|
||||
data: apiPurchaseChannelSummaryByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap")),
|
||||
},
|
||||
{
|
||||
title: "구매 채널(상세)",
|
||||
chartMode: "horizontal",
|
||||
data: apiPurchaseChannelByYear.filter(r => !(r.year === 26 && r.rowLabel === "gap")),
|
||||
data: apiPurchaseChannelByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap")),
|
||||
chartHeight: 550,
|
||||
},
|
||||
], []);
|
||||
|
||||
useEffect(() => {
|
||||
registerExcelExporter(async (payload) => {
|
||||
|
||||
const sheetName = `${filterValue.product}_${(filterValue.type as CategoryTypeValue).label}_구매 채널`
|
||||
const h3 = buildHeader_Banner(BANNER_GROUP, BANNER_KEY_MAP);
|
||||
|
||||
type AnyRow = Record<string, any>;
|
||||
const sections: Section<AnyRow>[] = tableDataArray.flatMap((tableData) => {
|
||||
const years = [YEARS.at(-1), YEARS.at(-2)];
|
||||
|
||||
return years.map((year) => ({
|
||||
title: `${tableData.title}_${year}년`,
|
||||
header: h3,
|
||||
rows: tableData.data.filter((d) => d.year === year) as AnyRow[],
|
||||
rowGap: 1,
|
||||
}));
|
||||
});
|
||||
|
||||
await exportDashboardExcel({
|
||||
fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`,
|
||||
sheetName: sheetName,
|
||||
sections: sections,
|
||||
});
|
||||
});
|
||||
return () => registerExcelExporter(null);
|
||||
}, [registerExcelExporter]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
{tableDataArray.map((tableData) => (
|
||||
|
||||
@@ -1,23 +1,53 @@
|
||||
'use client'
|
||||
|
||||
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
|
||||
import {useMemo} from "react";
|
||||
import {useEffect, useMemo} from "react";
|
||||
import {PageData, ServerBannerRow} from "@/types/lg";
|
||||
import {apiFridgeDoorTypeByYear} from "@/config/sample.data";
|
||||
import {CategoryByData} from "@/components/lge-dashboard";
|
||||
import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR, YEARS} from "@/const/lgConst";
|
||||
import {CategoryTypeValue} from "@/components/layout/CategoryFilter";
|
||||
import {buildHeader_Banner, exportDashboardExcel, Section} from "@/lib/lg-export-excel";
|
||||
|
||||
const TypeSpec = () => {
|
||||
const { filterValue } = useLayoutFilter();
|
||||
const { filterValue, registerExcelExporter } = useLayoutFilter();
|
||||
console.log(filterValue);
|
||||
|
||||
const tableDataArray = useMemo<PageData<ServerBannerRow>[]>(() => [
|
||||
{
|
||||
title: "타입",
|
||||
chartMode: "horizontal",
|
||||
data: apiFridgeDoorTypeByYear.filter(r => !(r.year === 26 && r.rowLabel === "gap")),
|
||||
data: apiFridgeDoorTypeByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap")),
|
||||
},
|
||||
], []);
|
||||
|
||||
useEffect(() => {
|
||||
registerExcelExporter(async (payload) => {
|
||||
|
||||
const sheetName = `${filterValue.product}_${(filterValue.type as CategoryTypeValue).label}_타입/스펙`
|
||||
const h3 = buildHeader_Banner(BANNER_GROUP, BANNER_KEY_MAP);
|
||||
|
||||
type AnyRow = Record<string, any>;
|
||||
const sections: Section<AnyRow>[] = tableDataArray.flatMap((tableData) => {
|
||||
const years = [YEARS.at(-1), YEARS.at(-2)];
|
||||
|
||||
return years.map((year) => ({
|
||||
title: `${tableData.title}_${year}년`,
|
||||
header: h3,
|
||||
rows: tableData.data.filter((d) => d.year === year) as AnyRow[],
|
||||
rowGap: 1,
|
||||
}));
|
||||
});
|
||||
|
||||
await exportDashboardExcel({
|
||||
fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`,
|
||||
sheetName: sheetName,
|
||||
sections: sections,
|
||||
});
|
||||
});
|
||||
return () => registerExcelExporter(null);
|
||||
}, [registerExcelExporter]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
{tableDataArray.map((tableData) => (
|
||||
|
||||
Reference in New Issue
Block a user