docs: 견적 V2 변경 이력 및 계획 문서 추가

- 견적 V2 API 연동 변경 이력 (4개 파일)
- 입고관리 분석 계획
- 재고 통합 계획

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-26 22:12:17 +09:00
parent 2893874137
commit 0cb8a3af22
6 changed files with 1257 additions and 0 deletions

View File

@@ -0,0 +1,141 @@
# 변경 내용 요약
**날짜:** 2026-01-26
**작업자:** Claude Code
**관련 계획:** docs/plans/quote-management-url-migration-plan.md (Step 1.3, 1.4)
## 📋 변경 개요
V2 견적 상세/수정 테스트 페이지(test/[id])에서 Mock 데이터를 실제 API 연동으로 변경
## 📁 수정된 파일
- `react/src/app/[locale]/(protected)/sales/quote-management/test/[id]/page.tsx` - API 연동 구현
## 🔧 상세 변경 사항
### 1. Import 추가
```typescript
import { getQuoteById, updateQuote } from "@/components/quotes/actions";
import { transformApiToV2, transformV2ToApi } from "@/components/quotes/types";
```
### 2. MOCK_DATA 제거
- 65줄의 하드코딩된 테스트 데이터 제거
### 3. useEffect 수정 (데이터 로드)
**변경 전:**
```typescript
useEffect(() => {
const loadQuote = async () => {
setIsLoading(true);
try {
await new Promise((resolve) => setTimeout(resolve, 500)); // Mock delay
setQuote({ ...MOCK_DATA, id: quoteId });
} catch (error) {
toast.error("견적 정보를 불러오는데 실패했습니다.");
router.push("/sales/quote-management");
} finally {
setIsLoading(false);
}
};
loadQuote();
}, [quoteId, router]);
```
**변경 후:**
```typescript
useEffect(() => {
const loadQuote = async () => {
setIsLoading(true);
try {
const result = await getQuoteById(quoteId);
if (!result.success || !result.data) {
toast.error(result.error || "견적 정보를 불러오는데 실패했습니다.");
router.push("/sales/quote-management");
return;
}
// API 응답을 V2 폼 데이터로 변환
const v2Data = transformApiToV2(result.data);
setQuote(v2Data);
} catch (error) {
toast.error("견적 정보를 불러오는데 실패했습니다.");
router.push("/sales/quote-management");
} finally {
setIsLoading(false);
}
};
if (quoteId) {
loadQuote();
}
}, [quoteId, router]);
```
### 4. handleSave 수정 (수정 저장)
**변경 전:**
```typescript
const handleSave = useCallback(async (data: QuoteFormDataV2, saveType: "temporary" | "final") => {
setIsSaving(true);
try {
console.log("[테스트] 수정 데이터:", data);
await new Promise((resolve) => setTimeout(resolve, 1000)); // Mock delay
toast.success(`[테스트] ${saveType === "temporary" ? "임시" : "최종"} 저장 완료`);
if (saveType === "final") {
router.push(`/sales/quote-management/test/${quoteId}`);
}
} catch (error) {
toast.error("저장 중 오류가 발생했습니다.");
} finally {
setIsSaving(false);
}
}, [router, quoteId]);
```
**변경 후:**
```typescript
const handleSave = useCallback(async (data: QuoteFormDataV2, saveType: "temporary" | "final") => {
setIsSaving(true);
try {
// V2 폼 데이터를 API 형식으로 변환
const updatedData = { ...data, status: saveType };
const apiData = transformV2ToApi(updatedData);
// API 호출
const result = await updateQuote(quoteId, apiData);
if (!result.success) {
toast.error(result.error || "저장 중 오류가 발생했습니다.");
return;
}
toast.success(`${saveType === "temporary" ? "임시" : "최종"} 저장 완료`);
// 저장 후 view 모드로 전환
router.push(`/sales/quote-management/test/${quoteId}`);
} catch (error) {
toast.error("저장 중 오류가 발생했습니다.");
} finally {
setIsSaving(false);
}
}, [router, quoteId]);
```
## ✅ Phase 1 완료
- [x] Step 1.1: V2 데이터 변환 함수 구현
- [x] Step 1.2: test-new 페이지 API 연동 (createQuote)
- [x] Step 1.3: test/[id] 상세 페이지 API 연동 (getQuoteById)
- [x] Step 1.4: test/[id] 수정 API 연동 (updateQuote)
## 🔜 다음 작업 (Phase 2)
- [ ] Step 2.1: test-new → new 경로 변경
- [ ] Step 2.2: test/[id] → [id] 경로 통합
- [ ] Step 2.3: 기존 V1 페이지 처리 결정
## 🔗 관련 문서
- 계획 문서: `docs/plans/quote-management-url-migration-plan.md`
- Step 1.1 변경 내역: `docs/changes/20260126_quote_v2_transform_functions.md`
- Step 1.2 변경 내역: `docs/changes/20260126_quote_v2_test_new_api.md`
- V2 컴포넌트: `react/src/components/quotes/QuoteRegistrationV2.tsx`

View File

@@ -0,0 +1,81 @@
# 변경 내용 요약
**날짜:** 2026-01-26
**작업자:** Claude Code
**관련 계획:** docs/plans/quote-management-url-migration-plan.md (Step 1.2)
## 📋 변경 개요
V2 견적 등록 테스트 페이지(test-new)에서 Mock 저장을 실제 API 연동으로 변경
## 📁 수정된 파일
- `react/src/app/[locale]/(protected)/sales/quote-management/test-new/page.tsx` - API 연동 구현
## 🔧 상세 변경 사항
### 1. Import 추가
```typescript
import { createQuote } from '@/components/quotes/actions';
import { transformV2ToApi } from '@/components/quotes/types';
```
### 2. handleSave 함수 수정
**변경 전:**
```typescript
const handleSave = useCallback(async (data: QuoteFormDataV2, saveType: 'temporary' | 'final') => {
setIsSaving(true);
try {
// TODO: API 연동 시 실제 저장 로직 구현
console.log('[테스트] 저장 데이터:', data);
await new Promise((resolve) => setTimeout(resolve, 1000)); // Mock delay
toast.success(`[테스트] ${saveType === 'temporary' ? '임시' : '최종'} 저장 완료`);
if (saveType === 'final') {
router.push('/sales/quote-management/test/1'); // 하드코딩된 ID
}
} catch (error) {
toast.error('저장 중 오류가 발생했습니다.');
} finally {
setIsSaving(false);
}
}, [router]);
```
**변경 후:**
```typescript
const handleSave = useCallback(async (data: QuoteFormDataV2, saveType: 'temporary' | 'final') => {
setIsSaving(true);
try {
// V2 폼 데이터를 API 형식으로 변환
const updatedData = { ...data, status: saveType };
const apiData = transformV2ToApi(updatedData);
// API 호출
const result = await createQuote(apiData);
if (!result.success) {
toast.error(result.error || '저장 중 오류가 발생했습니다.');
return;
}
toast.success(`${saveType === 'temporary' ? '임시' : '최종'} 저장 완료`);
// 저장 후 상세 페이지로 이동 (실제 생성된 ID 사용)
if (result.data?.id) {
router.push(`/sales/quote-management/test/${result.data.id}`);
}
} catch (error) {
toast.error('저장 중 오류가 발생했습니다.');
} finally {
setIsSaving(false);
}
}, [router]);
```
## ✅ 다음 작업 (Phase 1.3~1.4)
- [ ] test/[id] 상세 페이지 API 연동 (getQuoteById)
- [ ] test/[id] 수정 API 연동 (updateQuote)
## 🔗 관련 문서
- 계획 문서: `docs/plans/quote-management-url-migration-plan.md`
- Step 1.1 변경 내역: `docs/changes/20260126_quote_v2_transform_functions.md`
- V2 컴포넌트: `react/src/components/quotes/QuoteRegistrationV2.tsx`

View File

@@ -0,0 +1,86 @@
# 변경 내용 요약
**날짜:** 2026-01-26
**작업자:** Claude Code
**관련 계획:** docs/plans/quote-management-url-migration-plan.md (Step 1.1)
## 📋 변경 개요
V2 견적 컴포넌트(QuoteRegistrationV2)에서 사용할 데이터 변환 함수 구현
- `transformV2ToApi`: V2 폼 데이터 → API 요청 형식
- `transformApiToV2`: API 응답 → V2 폼 데이터
## 📁 수정된 파일
- `react/src/components/quotes/types.ts` - V2 타입 정의 및 변환 함수 추가
## 🔧 상세 변경 사항
### 1. LocationItem 인터페이스 추가
발주 개소 항목의 데이터 구조 정의
```typescript
export interface LocationItem {
id: string;
floor: string; // 층
code: string; // 부호
openWidth: number; // 가로 (오픈사이즈 W)
openHeight: number; // 세로 (오픈사이즈 H)
productCode: string; // 제품코드
productName: string; // 제품명
quantity: number; // 수량
guideRailType: string; // 가이드레일 설치 유형
motorPower: string; // 모터 전원
controller: string; // 연동제어기
wingSize: number; // 마구리 날개치수
inspectionFee: number; // 검사비
// 계산 결과 (선택)
unitPrice?: number;
totalPrice?: number;
bomResult?: BomCalculationResult;
}
```
### 2. QuoteFormDataV2 인터페이스 추가
V2 컴포넌트용 폼 데이터 구조
```typescript
export interface QuoteFormDataV2 {
id?: string;
registrationDate: string;
writer: string;
clientId: string;
clientName: string;
siteName: string;
manager: string;
contact: string;
dueDate: string;
remarks: string;
status: 'draft' | 'temporary' | 'final';
locations: LocationItem[]; // V1의 items[] 대신 locations[] 사용
}
```
### 3. transformV2ToApi 함수 구현
V2 폼 데이터를 API 요청 형식으로 변환
**핵심 로직:**
1. `locations[]``calculation_inputs.items[]` (폼 복원용)
2. BOM 결과가 있으면 자재 상세를 `items[]`에 포함
3. 없으면 완제품 기준으로 `items[]` 생성
4. status 매핑: `final``finalized`, 나머지 → `draft`
### 4. transformApiToV2 함수 구현
API 응답을 V2 폼 데이터로 변환
**핵심 로직:**
1. `calculation_inputs.items[]``locations[]` 복원
2. 관련 BOM 자재에서 금액 계산
3. status 매핑: `finalized/converted``final`, 나머지 → `draft`
## ✅ 다음 작업 (Phase 1.2~1.4)
- [ ] test-new 페이지 API 연동 (createQuote)
- [ ] test/[id] 상세 페이지 API 연동 (getQuoteById)
- [ ] test/[id] 수정 API 연동 (updateQuote)
## 🔗 관련 문서
- 계획 문서: `docs/plans/quote-management-url-migration-plan.md`
- V2 컴포넌트: `react/src/components/quotes/QuoteRegistrationV2.tsx`

View File

@@ -0,0 +1,76 @@
# 변경 내용 요약
**날짜:** 2026-01-26
**작업자:** Claude Code
**관련 계획:** docs/plans/quote-management-url-migration-plan.md (Phase 1 버그 수정)
## 📋 변경 개요
V2 견적 등록 컴포넌트에서 작성자 필드가 "드미트리"로 하드코딩된 버그 수정
## 📁 수정된 파일
- `react/src/components/quotes/QuoteRegistrationV2.tsx` - 로그인 사용자 정보 연동
## 🔧 상세 변경 사항
### 1. Import 추가
```typescript
import { useAuth } from "@/contexts/AuthContext";
```
### 2. INITIAL_FORM_DATA 수정
**변경 전:**
```typescript
const INITIAL_FORM_DATA: QuoteFormDataV2 = {
registrationDate: new Date().toISOString().split("T")[0],
writer: "드미트리", // TODO: 로그인 사용자 정보
// ...
};
```
**변경 후:**
```typescript
const INITIAL_FORM_DATA: QuoteFormDataV2 = {
registrationDate: new Date().toISOString().split("T")[0],
writer: "", // useAuth()에서 currentUser.name으로 설정됨
// ...
};
```
### 3. useAuth 훅 사용
```typescript
export function QuoteRegistrationV2({ ... }) {
// 인증 정보
const { currentUser } = useAuth();
// 상태 초기화 시 currentUser.name 사용
const [formData, setFormData] = useState<QuoteFormDataV2>(() => {
const data = initialData || INITIAL_FORM_DATA;
// create 모드에서 writer가 비어있으면 현재 사용자명으로 설정
if (mode === "create" && !data.writer && currentUser?.name) {
return { ...data, writer: currentUser.name };
}
return data;
});
// ...
}
```
### 4. useEffect로 지연 로딩 처리
```typescript
// 작성자 자동 설정 (create 모드에서 currentUser 로드 시)
useEffect(() => {
if (mode === "create" && !formData.writer && currentUser?.name) {
setFormData((prev) => ({ ...prev, writer: currentUser.name }));
}
}, [mode, currentUser?.name, formData.writer]);
```
## ✅ 동작 방식
1. **초기 렌더링**: useState 초기화 시 currentUser.name 사용
2. **지연 로딩**: currentUser가 나중에 로드되면 useEffect로 writer 업데이트
3. **edit/view 모드**: initialData의 writer 값 유지 (덮어쓰지 않음)
## 🔗 관련 문서
- 계획 문서: `docs/plans/quote-management-url-migration-plan.md`
- AuthContext: `react/src/contexts/AuthContext.tsx`