Files
sam-docs/changes/20260126_quote_v2_test_new_api.md
권혁성 0cb8a3af22 docs: 견적 V2 변경 이력 및 계획 문서 추가
- 견적 V2 API 연동 변경 이력 (4개 파일)
- 입고관리 분석 계획
- 재고 통합 계획

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 22:12:17 +09:00

2.6 KiB

변경 내용 요약

날짜: 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 추가

import { createQuote } from '@/components/quotes/actions';
import { transformV2ToApi } from '@/components/quotes/types';

2. handleSave 함수 수정

변경 전:

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]);

변경 후:

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