260202_03_ENH: 페이지 깜빡임 최소화 및 카테고리에서 전체로 이동 시 페이지 렌더링 2회 되는 부분 수정
This commit is contained in:
@@ -3,13 +3,12 @@
|
||||
import {useMemo} from "react";
|
||||
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
|
||||
import {CategoryByData} from "@/components/lge-dashboard";
|
||||
import {apiBrandShareByYear, apiPaymentMethodByYear} from "@/config/sample.data";
|
||||
import {apiBrandShareByYear} from "@/config/sample.data";
|
||||
import {PageData, ServerBannerRow} from "@/types/lg";
|
||||
import {buildGapRow} from "@/lib/lg-dashboard";
|
||||
|
||||
const Brand = () => {
|
||||
const { filterValue } = useLayoutFilter();
|
||||
console.log(filterValue);
|
||||
|
||||
const tableDataArray = useMemo<PageData<ServerBannerRow>[]>(() => {
|
||||
const cleaned = apiBrandShareByYear.filter(
|
||||
|
||||
@@ -2,19 +2,15 @@
|
||||
|
||||
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
|
||||
import BannerSummary from "@/components/lge-dashboard/combo/BannerSummary";
|
||||
import {useEffect, useState} from "react";
|
||||
import {useEffect, useMemo, useState} from "react";
|
||||
import {ServerBannerRow} from "@/types/lg";
|
||||
import {apiYearIndex} from "@/config/sample.data";
|
||||
import {apiOwnershipSummary, apiPurchaseRateKpis, apiYearIndex} from "@/config/sample.data";
|
||||
|
||||
const PenetrationChange = () => {
|
||||
const { filterValue } = useLayoutFilter();
|
||||
console.log(filterValue);
|
||||
|
||||
const [penetrationChangeData, setPenetrationChangeData] = useState<ServerBannerRow[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
setPenetrationChangeData(apiYearIndex)
|
||||
},[])
|
||||
const penetrationChangeData = useMemo<ServerBannerRow[]>(() => apiYearIndex, []);
|
||||
|
||||
return(
|
||||
<BannerSummary data={penetrationChangeData} useChart={true} />
|
||||
|
||||
@@ -2,37 +2,29 @@
|
||||
|
||||
import {useLayoutFilter} from "@/components/layout/LayoutFilterContext";
|
||||
import BannerSummary from "@/components/lge-dashboard/combo/BannerSummary";
|
||||
import {useEffect, useMemo, useState} from "react";
|
||||
import { useMemo } from "react";
|
||||
import {ServerBannerRow} from "@/types/lg";
|
||||
import {apiOwnershipSummary, apiPurchaseRateKpis} from "@/config/sample.data";
|
||||
|
||||
const Profile = () => {
|
||||
const { isTotal, filterValue } = useLayoutFilter();
|
||||
const [profileData, setProfileData] = useState<ServerBannerRow[]>([]);
|
||||
|
||||
const typeLabel = useMemo(() => {
|
||||
if (isTotal) return null; // SelectedMap 경로
|
||||
return filterValue.type.label; // CategoryFilterValue 경로로 TS가 좁혀짐
|
||||
}, [isTotal, filterValue]);
|
||||
const profileData = useMemo<ServerBannerRow[]>(() => {
|
||||
if (isTotal) return [];
|
||||
|
||||
useEffect(() => {
|
||||
if (!typeLabel) return;
|
||||
const typeLabel = filterValue.type.label;
|
||||
|
||||
switch (typeLabel) {
|
||||
case "보유":
|
||||
setProfileData(apiOwnershipSummary);
|
||||
break;
|
||||
return apiOwnershipSummary;
|
||||
case "구매":
|
||||
setProfileData(apiPurchaseRateKpis);
|
||||
break;
|
||||
return apiPurchaseRateKpis;
|
||||
case "향후 구매":
|
||||
setProfileData(apiPurchaseRateKpis);
|
||||
break;
|
||||
return apiPurchaseRateKpis;
|
||||
default:
|
||||
setProfileData([]);
|
||||
break;
|
||||
return [];
|
||||
}
|
||||
}, [typeLabel]);
|
||||
}, [isTotal, filterValue]);
|
||||
|
||||
return (
|
||||
<BannerSummary data={profileData} useChart={false} />
|
||||
|
||||
Reference in New Issue
Block a user