260127_01_ENH: 커스텀 컴포넌트들 1차 완성 및 일부페이지에 SampleData 적용
This commit is contained in:
368
src/config/sample.data.ts
Normal file
368
src/config/sample.data.ts
Normal file
@@ -0,0 +1,368 @@
|
||||
// sample.data.ts
|
||||
import {
|
||||
ProductKey,
|
||||
BannerKey,
|
||||
ServerBannerRow,
|
||||
ServerProductRow,
|
||||
} from "@/components/lge-dashboard";
|
||||
import {PRODUCT_KEY_MAP} from "@/components/lge-dashboard";
|
||||
|
||||
const PRODUCT_KEYS = Object.keys(PRODUCT_KEY_MAP) as ProductKey[];
|
||||
|
||||
const randInt = (min: number, max: number) =>
|
||||
Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
|
||||
type RandRange = { min: number | null; max: number | null };
|
||||
|
||||
const makeProductDist = (range?: RandRange): Record<ProductKey, number> => {
|
||||
const min = range?.min ?? 1;
|
||||
const max = range?.max ?? 60;
|
||||
|
||||
const out = {} as Record<ProductKey, number>;
|
||||
for (const k of PRODUCT_KEYS) out[k] = randInt(min, max);
|
||||
return out;
|
||||
};
|
||||
|
||||
const productRow = (
|
||||
year: number,
|
||||
rowLabel: string,
|
||||
total: number,
|
||||
range: RandRange = { min: null, max: null },
|
||||
extra?: Partial<Record<ProductKey, number>>,
|
||||
): ServerProductRow => ({
|
||||
year,
|
||||
rowLabel,
|
||||
total,
|
||||
...makeProductDist(range),
|
||||
...(extra ?? {}),
|
||||
});
|
||||
|
||||
const round1 = (n: number) => Math.round(n * 10) / 10;
|
||||
|
||||
const calcGapRow = (row26: ServerProductRow, row25: ServerProductRow): ServerProductRow => {
|
||||
const out: ServerProductRow = {
|
||||
year: row26.year,
|
||||
rowLabel: "gap",
|
||||
total: row26.total - row25.total,
|
||||
};
|
||||
for (const k of PRODUCT_KEYS) {
|
||||
const a = row26[k] ?? 0;
|
||||
const b = row25[k] ?? 0;
|
||||
out[k] = a - b;
|
||||
}
|
||||
return out;
|
||||
};
|
||||
|
||||
const calcCagrRow = (row24: ServerProductRow, row26: ServerProductRow): ServerProductRow => {
|
||||
const years = 2; // 24 -> 26
|
||||
const out: ServerProductRow = { year: row26.year, rowLabel: "CAGR", total: 0 };
|
||||
|
||||
// total은 참고용으로만: (26/24) CAGR %
|
||||
out.total =
|
||||
row24.total > 0 ? round1((Math.pow(row26.total / row24.total, 1 / years) - 1) * 100) : 0;
|
||||
|
||||
for (const k of PRODUCT_KEYS) {
|
||||
const v24 = row24[k] ?? 0;
|
||||
const v26 = row26[k] ?? 0;
|
||||
out[k] = v24 > 0 ? round1((Math.pow(v26 / v24, 1 / years) - 1) * 100) : 0;
|
||||
}
|
||||
return out;
|
||||
};
|
||||
|
||||
// 배너(41키) 그룹별 합이 100 되도록 고정 분포
|
||||
const BANNER_DIST_DEFAULT: Record<BannerKey, number> = {
|
||||
// 라이프스테이지(6)
|
||||
single: 20,
|
||||
noKids: 20,
|
||||
preschoolKids: 20,
|
||||
schoolKids: 20,
|
||||
adultKids: 10,
|
||||
independentSenior: 10,
|
||||
|
||||
// 가구원수(4)
|
||||
hh1: 25,
|
||||
hh2: 35,
|
||||
hh3: 20,
|
||||
hh4Plus: 20,
|
||||
|
||||
// 연령(5)
|
||||
age20s: 15,
|
||||
age30s: 25,
|
||||
age40s: 30,
|
||||
age50s: 20,
|
||||
age60s: 10,
|
||||
|
||||
// 점유형태(5)
|
||||
ownerOccupied: 50,
|
||||
jeonse: 25,
|
||||
depositAndMonthly: 10,
|
||||
monthlyNoDeposit: 10,
|
||||
otherTenure: 5,
|
||||
|
||||
// 주거형태(6)
|
||||
apartment: 60,
|
||||
house: 15,
|
||||
officetel: 10,
|
||||
villa: 10,
|
||||
studio: 3,
|
||||
otherHousingType: 2,
|
||||
|
||||
// 평형(5)
|
||||
under19Pyeong: 10,
|
||||
pyeong20s: 20,
|
||||
pyeong30s: 35,
|
||||
pyeong40s: 20,
|
||||
pyeong50Plus: 15,
|
||||
|
||||
// 권역(6)
|
||||
regionCapital: 45,
|
||||
regionGyeongnamBusanUlsan: 15,
|
||||
regionGyeongbukDaegu: 10,
|
||||
regionJeollaGwangju: 10,
|
||||
regionChungcheongDaejeonSejong: 10,
|
||||
regionGangwonJeju: 10,
|
||||
|
||||
// 소득(4)
|
||||
incomeUnder299: 20,
|
||||
income300to599: 40,
|
||||
income600to899: 25,
|
||||
income900Plus: 15,
|
||||
};
|
||||
|
||||
const bannerRow = (year: number, rowLabel: string, total: number, extra?: Record<string, number>): ServerBannerRow => ({
|
||||
year,
|
||||
rowLabel,
|
||||
total,
|
||||
...BANNER_DIST_DEFAULT,
|
||||
...(extra ?? {}),
|
||||
});
|
||||
|
||||
const TREND_24: ServerProductRow = productRow(24, "24년", 45, {min:70, max:99});
|
||||
const TREND_25: ServerProductRow = productRow(25, "25년", 46, {min:70, max:99});
|
||||
const TREND_26: ServerProductRow = productRow(26, "26년", 48, {min:70, max:99});
|
||||
|
||||
export const apiTrendCategories: ServerProductRow[] = [
|
||||
calcGapRow(TREND_26, TREND_25),
|
||||
TREND_24,
|
||||
TREND_25,
|
||||
TREND_26,
|
||||
calcCagrRow(TREND_24, TREND_26),
|
||||
];
|
||||
|
||||
export const apiBrandByYearCategories: ServerProductRow[] = [
|
||||
productRow(24, "LG", 1200),
|
||||
productRow(24, "Samsung", 1300),
|
||||
productRow(24, "Cbrand", 600),
|
||||
|
||||
productRow(25, "LG", 1250),
|
||||
productRow(25, "Samsung", 1320),
|
||||
productRow(25, "Cbrand", 620),
|
||||
|
||||
productRow(26, "LG", 1280),
|
||||
productRow(26, "Samsung", 1340),
|
||||
productRow(26, "Cbrand", 640),
|
||||
];
|
||||
|
||||
const OWN_PEN_24: ServerProductRow = productRow(24, "24년", 45);
|
||||
const OWN_PEN_25: ServerProductRow = productRow(25, "25년", 46);
|
||||
const OWN_PEN_26: ServerProductRow = productRow(26, "26년", 48);
|
||||
|
||||
export const apiOwnShareOfTotalPenetration: ServerProductRow[] = [
|
||||
calcGapRow(OWN_PEN_26, OWN_PEN_25),
|
||||
OWN_PEN_24,
|
||||
OWN_PEN_25,
|
||||
OWN_PEN_26,
|
||||
];
|
||||
|
||||
const BUY_24: ServerProductRow = productRow(24, "24년", 45, {min:20, max:40});
|
||||
const BUY_25: ServerProductRow = productRow(25, "25년", 46, {min:20, max:40});
|
||||
const BUY_26: ServerProductRow = productRow(26, "26년", 48, {min:20, max:40});
|
||||
export const apiTrendBuy: ServerProductRow[] = [
|
||||
calcGapRow(TREND_26, TREND_25),
|
||||
BUY_24,
|
||||
BUY_25,
|
||||
BUY_26,
|
||||
];
|
||||
|
||||
const OWN_BUY_24: ServerProductRow = productRow(24, "24년", 41, {min:5, max:20});
|
||||
const OWN_BUY_25: ServerProductRow = productRow(25, "25년", 42, {min:5, max:20});
|
||||
const OWN_BUY_26: ServerProductRow = productRow(26, "26년", 43, {min:5, max:20});
|
||||
|
||||
export const apiOwnShareOfTotalPurchase: ServerProductRow[] = [
|
||||
calcGapRow(OWN_BUY_26, OWN_BUY_25),
|
||||
productRow(26, "전체 구입율 중 자사제품 비율", 46),
|
||||
OWN_BUY_24,
|
||||
OWN_BUY_25,
|
||||
OWN_BUY_26,
|
||||
];
|
||||
|
||||
export const apiLifeStageByProduct: ServerBannerRow[] = [
|
||||
bannerRow(26, "냉장고", 1200, { single: 18, noKids: 22, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }),
|
||||
bannerRow(26, "세탁기", 1100, { single: 18, noKids: 22, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }),
|
||||
bannerRow(26, "에어컨", 900, { single: 22, noKids: 18, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }),
|
||||
bannerRow(26, "TV", 950, { single: 18, noKids: 22, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }),
|
||||
bannerRow(26, "청소기", 1000, { single: 22, noKids: 18, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }),
|
||||
bannerRow(26, "김치 냉장고", 700, { single: 22, noKids: 18, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }),
|
||||
bannerRow(26, "공기 청정기", 800, { single: 22, noKids: 18, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }),
|
||||
bannerRow(26, "가습기", 650, { single: 22, noKids: 18, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }),
|
||||
bannerRow(26, "제습기", 600, { single: 18, noKids: 22, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }),
|
||||
bannerRow(26, "건조기", 500, { single: 18, noKids: 22, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }),
|
||||
bannerRow(26, "식기세척기", 450, { single: 22, noKids: 18, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }),
|
||||
bannerRow(26, "의류 관리기", 320, { single: 18, noKids: 22, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }),
|
||||
bannerRow(26, "로봇 청소기", 420, { single: 22, noKids: 18, preschoolKids: 20, schoolKids: 20, adultKids: 10, independentSenior: 10 }),
|
||||
];
|
||||
|
||||
/** ---------------------------
|
||||
* API #6
|
||||
* year rowLabel total banner
|
||||
* 26 사례수 / 보유율 / gap / 보유대수
|
||||
* -------------------------- */
|
||||
export const apiOwnershipSummary: ServerBannerRow[] = [
|
||||
bannerRow(26, "사례수", 2000),
|
||||
bannerRow(26, "보유율", 85),
|
||||
bannerRow(26, "gap", 1), // 26-25
|
||||
bannerRow(26, "보유대수", 1.2),
|
||||
];
|
||||
|
||||
/** ---------------------------
|
||||
* API #7
|
||||
* year rowLabel total banner
|
||||
* 26 사례수
|
||||
* 26 26
|
||||
* 25 25
|
||||
* 24 24
|
||||
* -------------------------- */
|
||||
export const apiYearIndex: ServerBannerRow[] = [
|
||||
bannerRow(26, "사례수", 2000),
|
||||
bannerRow(26, "26", 100),
|
||||
bannerRow(25, "25", 100),
|
||||
bannerRow(24, "24", 100),
|
||||
];
|
||||
|
||||
/** ---------------------------
|
||||
* API #8
|
||||
* year rowLabel total banner
|
||||
* 25/26 사례수 + 브랜드
|
||||
* -------------------------- */
|
||||
export const apiBrandShareByYear: ServerBannerRow[] = [
|
||||
bannerRow(25, "사례수", 500),
|
||||
bannerRow(25, "lg", 48),
|
||||
bannerRow(25, "삼성", 40),
|
||||
bannerRow(25, "위니아", 4),
|
||||
bannerRow(25, "캐리어", 3),
|
||||
bannerRow(25, "하이얼", 1),
|
||||
bannerRow(25, "기타", 4),
|
||||
|
||||
bannerRow(26, "사례수", 520),
|
||||
bannerRow(26, "lg", 47),
|
||||
bannerRow(26, "삼성", 40),
|
||||
bannerRow(26, "위니아", 5),
|
||||
bannerRow(26, "캐리어", 3),
|
||||
bannerRow(26, "하이얼", 1),
|
||||
bannerRow(26, "기타", 4),
|
||||
];
|
||||
|
||||
/** ---------------------------
|
||||
* API #9
|
||||
* year rowLabel total banner
|
||||
* 25/26 사례수 + 도어 타입
|
||||
* -------------------------- */
|
||||
export const apiFridgeDoorTypeByYear: ServerBannerRow[] = [
|
||||
bannerRow(25, "사례수", 480),
|
||||
bannerRow(25, "1도어", 5),
|
||||
bannerRow(25, "2도어 상 냉동+하 냉장", 22),
|
||||
bannerRow(25, "2도어 상 냉장+하 냉동", 8),
|
||||
bannerRow(25, "2도어 양문형", 36),
|
||||
bannerRow(25, "4도어", 28),
|
||||
bannerRow(25, "기타", 1),
|
||||
|
||||
bannerRow(26, "사례수", 500),
|
||||
bannerRow(26, "1도어", 5),
|
||||
bannerRow(26, "2도어 상 냉동+하 냉장", 23),
|
||||
bannerRow(26, "2도어 상 냉장+하 냉동", 12),
|
||||
bannerRow(26, "2도어 양문형", 35),
|
||||
bannerRow(26, "4도어", 25),
|
||||
bannerRow(26, "기타", 0),
|
||||
];
|
||||
|
||||
/** ---------------------------
|
||||
* API #10
|
||||
* year rowLabel total banner
|
||||
* 25/26 사례수 + 보유 경로(구매 경로)
|
||||
* -------------------------- */
|
||||
export const apiPurchasePathByYear: ServerBannerRow[] = [
|
||||
bannerRow(25, "사례수", 520),
|
||||
bannerRow(25, "신규 구입", 8),
|
||||
bannerRow(25, "기존 제품 작동하나 신규 구입", 4),
|
||||
bannerRow(25, "기존 제품 고장으로 신규 구입", 40),
|
||||
bannerRow(25, "추가 구입", 48),
|
||||
|
||||
bannerRow(26, "사례수", 540),
|
||||
bannerRow(26, "신규 구입", 8),
|
||||
bannerRow(26, "기존 제품 작동하나 신규 구입", 4),
|
||||
bannerRow(26, "기존 제품 고장으로 신규 구입", 40),
|
||||
bannerRow(26, "추가 구입", 48),
|
||||
];
|
||||
|
||||
/** ---------------------------
|
||||
* API #11
|
||||
* year rowLabel total banner
|
||||
* 25/26 결제수단
|
||||
* -------------------------- */
|
||||
export const apiPaymentMethodByYear: ServerBannerRow[] = [
|
||||
bannerRow(25, "일시불", 60),
|
||||
bannerRow(25, "할부", 30),
|
||||
bannerRow(25, "렌탈", 10),
|
||||
|
||||
bannerRow(26, "일시불", 58),
|
||||
bannerRow(26, "할부", 32),
|
||||
bannerRow(26, "렌탈", 10),
|
||||
];
|
||||
|
||||
/** ---------------------------
|
||||
* API #12
|
||||
* year rowLabel total banner
|
||||
* 26 사례수 / 구매율 / gap
|
||||
* -------------------------- */
|
||||
export const apiPurchaseRateKpis: ServerBannerRow[] = [
|
||||
bannerRow(26, "사례수", 700),
|
||||
bannerRow(26, "구매율", 35),
|
||||
bannerRow(26, "gap", 2), // 26-25
|
||||
];
|
||||
|
||||
/** ---------------------------
|
||||
* API #13
|
||||
* year rowLabel total banner
|
||||
* 25/26 사례수 + 유통채널
|
||||
* -------------------------- */
|
||||
export const apiPurchaseChannelByYear: ServerBannerRow[] = [
|
||||
bannerRow(25, "사례수", 650),
|
||||
bannerRow(25, "오프라인 단독 매장", 25),
|
||||
bannerRow(25, "전자제품 양판점", 20),
|
||||
bannerRow(25, "대형할인점", 10),
|
||||
bannerRow(25, "백화점", 5),
|
||||
bannerRow(25, "오픈마켓", 15),
|
||||
bannerRow(25, "제조사 공식 홈페이지", 8),
|
||||
bannerRow(25, "포털 쇼핑채널 입점몰", 4),
|
||||
bannerRow(25, "백화점 기반 쇼핑몰", 2),
|
||||
bannerRow(25, "TV 홈쇼핑", 3),
|
||||
bannerRow(25, "유통사 온라인 쇼핑몰", 4),
|
||||
bannerRow(25, "라이프스타일 쇼핑몰", 2),
|
||||
bannerRow(25, "해외 직구/대행 사이트", 1),
|
||||
bannerRow(25, "중고거래 사이트", 1),
|
||||
|
||||
bannerRow(26, "사례수", 680),
|
||||
bannerRow(26, "오프라인 단독 매장", 24),
|
||||
bannerRow(26, "전자제품 양판점", 20),
|
||||
bannerRow(26, "대형할인점", 10),
|
||||
bannerRow(26, "백화점", 5),
|
||||
bannerRow(26, "오픈마켓", 16),
|
||||
bannerRow(26, "제조사 공식 홈페이지", 9),
|
||||
bannerRow(26, "포털 쇼핑채널 입점몰", 4),
|
||||
bannerRow(26, "백화점 기반 쇼핑몰", 2),
|
||||
bannerRow(26, "TV 홈쇼핑", 3),
|
||||
bannerRow(26, "유통사 온라인 쇼핑몰", 3),
|
||||
bannerRow(26, "라이프스타일 쇼핑몰", 2),
|
||||
bannerRow(26, "해외 직구/대행 사이트", 1),
|
||||
bannerRow(26, "중고거래 사이트", 1),
|
||||
];
|
||||
Reference in New Issue
Block a user