feat(WEB): DevToolbar - 견적→수주→작업지시→출하 테스트 자동화 도구

- DevFillContext: 전역 상태 관리 (활성화/페이지 타입/폼 채우기 함수)
- DevToolbar: 플로팅 UI 컴포넌트 (토글/자동 채우기 버튼)
- useDevFill: 각 폼에서 자동 채우기 함수 등록 커스텀 훅
- 데이터 생성기: 견적/수주/작업지시/출하 샘플 데이터
- 환경변수 제어: NEXT_PUBLIC_DEV_TOOLBAR_ENABLED로 On/Off
- 통합: QuoteRegistration, OrderRegistration, WorkOrderCreate, ShipmentCreate
- Hydration 불일치 방지: useState 초기값 false + useEffect 패턴
This commit is contained in:
2026-01-20 20:38:29 +09:00
parent c101b8bf7e
commit eae23d4457
15 changed files with 1048 additions and 5 deletions

View File

@@ -0,0 +1,126 @@
/**
* 견적 샘플 데이터 생성기
*/
import {
randomPick,
randomInt,
randomInt100,
randomPhone,
dateAfterDays,
today,
randomFloor,
nextCode,
resetCodeCounter,
randomRemark,
tempId,
} from './index';
import type { QuoteFormData, QuoteItem } from '@/components/quotes/QuoteRegistration';
import type { Vendor } from '@/components/accounting/VendorManagement';
import type { FinishedGoods } from '@/components/quotes/actions';
// 제품 카테고리
const PRODUCT_CATEGORIES = ['SCREEN', 'STEEL'];
// 가이드레일 설치 유형
const GUIDE_RAIL_TYPES = ['wall', 'floor'];
// 모터 전원
const MOTOR_POWERS = ['single', 'three'];
// 연동제어기
const CONTROLLERS = ['basic', 'smart', 'premium'];
// 작성자 목록 (실제로는 로그인 사용자 사용)
const WRITERS = ['드미트리', '김철수', '이영희', '박지민', '최서연'];
/**
* 견적 품목 1개 생성
*/
export function generateQuoteItem(
index: number,
products?: FinishedGoods[]
): QuoteItem {
const category = randomPick(PRODUCT_CATEGORIES);
// 카테고리에 맞는 제품 필터링
let productName = '';
if (products && products.length > 0) {
const categoryProducts = products.filter(p =>
p.categoryCode?.toUpperCase() === category || !p.categoryCode
);
if (categoryProducts.length > 0) {
productName = randomPick(categoryProducts).name;
}
}
// 제품명이 없으면 기본값
if (!productName) {
productName = category === 'SCREEN'
? randomPick(['방화스크린 FSC-1', '방화스크린 FSC-2', '방화스크린 FSC-3'])
: randomPick(['방화철재셔터 FSD-1', '방화철재셔터 FSD-2']);
}
return {
id: tempId(),
floor: randomFloor(),
code: nextCode(),
productCategory: category,
productName,
openWidth: String(randomInt100(2000, 5000)),
openHeight: String(randomInt100(2000, 5000)),
guideRailType: randomPick(GUIDE_RAIL_TYPES),
motorPower: randomPick(MOTOR_POWERS),
controller: randomPick(CONTROLLERS),
quantity: randomInt(1, 10),
wingSize: '50',
inspectionFee: 50000,
};
}
/**
* 견적 폼 데이터 생성
*/
export interface GenerateQuoteDataOptions {
clients?: Vendor[]; // 거래처 목록
products?: FinishedGoods[]; // 제품 목록
itemCount?: number; // 품목 수 (기본: 1~5개 랜덤)
}
export function generateQuoteData(options: GenerateQuoteDataOptions = {}): QuoteFormData {
const { clients = [], products = [], itemCount } = options;
// 부호 카운터 리셋
resetCodeCounter();
// 거래처 선택
let clientId = '';
let clientName = '';
if (clients.length > 0) {
const client = randomPick(clients);
clientId = String(client.id);
clientName = client.name;
}
// 품목 수 결정
const count = itemCount ?? randomInt(1, 5);
// 품목 생성
const items: QuoteItem[] = [];
for (let i = 0; i < count; i++) {
items.push(generateQuoteItem(i, products));
}
return {
registrationDate: today(),
writer: randomPick(WRITERS),
clientId,
clientName,
siteName: clientName ? `${clientName} 현장` : '테스트 현장',
manager: randomPick(['김담당', '이담당', '박담당', '최담당']),
contact: randomPhone(),
dueDate: dateAfterDays(7), // 1주일 후
remarks: randomRemark(),
items,
};
}