From 9b1a1e3dc73ca5cab2862d3fcdda7fff2e42d790 Mon Sep 17 00:00:00 2001 From: kent Date: Fri, 9 Jan 2026 22:14:38 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20[=EC=88=98=EC=A3=BC=EA=B4=80=EB=A6=AC]?= =?UTF-8?q?=20=EC=88=98=EC=A3=BC=20=EB=93=B1=EB=A1=9D=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=EA=B1=B0=EB=9E=98=EC=B2=98=20API=20=EC=97=B0?= =?UTF-8?q?=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - SAMPLE_CLIENTS 하드코딩 제거 - useClientList 훅으로 실제 API 데이터 조회 - 로딩 상태 처리 ("불러오는 중...") - 견적 선택 시 발주처 필드 비활성화 --- src/components/orders/OrderRegistration.tsx | 30 ++++++++++++--------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/components/orders/OrderRegistration.tsx b/src/components/orders/OrderRegistration.tsx index 3585dc6b..deea1be9 100644 --- a/src/components/orders/OrderRegistration.tsx +++ b/src/components/orders/OrderRegistration.tsx @@ -13,6 +13,7 @@ import { useState, useEffect, useCallback } from "react"; import { useDaumPostcode } from "@/hooks/useDaumPostcode"; +import { useClientList } from "@/hooks/useClientList"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { Button } from "@/components/ui/button"; @@ -134,15 +135,6 @@ const SHIPPING_COSTS = [ { value: "negotiable", label: "협의" }, ]; -// 샘플 발주처 데이터 -const SAMPLE_CLIENTS = [ - { id: "C001", name: "태영건설(주)" }, - { id: "C002", name: "현대건설(주)" }, - { id: "C003", name: "GS건설(주)" }, - { id: "C004", name: "대우건설(주)" }, - { id: "C005", name: "포스코건설" }, -]; - interface OrderRegistrationProps { onBack: () => void; onSave: (formData: OrderFormData) => Promise; @@ -185,6 +177,14 @@ export function OrderRegistration({ const [isSaving, setIsSaving] = useState(false); const [fieldErrors, setFieldErrors] = useState({}); + // 거래처 목록 조회 + const { clients, fetchClients, isLoading: isClientsLoading } = useClientList(); + + // 컴포넌트 마운트 시 거래처 목록 불러오기 + useEffect(() => { + fetchClients({ onlyActive: true, size: 100 }); + }, [fetchClients]); + // Daum 우편번호 서비스 const { openPostcode } = useDaumPostcode({ onComplete: (result) => { @@ -231,6 +231,7 @@ export function OrderRegistration({ setForm((prev) => ({ ...prev, selectedQuotation: quotation, + clientId: quotation.clientId || "", // 견적의 발주처 ID 설정 clientName: quotation.client, siteName: quotation.siteName, manager: quotation.manager || "", @@ -238,6 +239,8 @@ export function OrderRegistration({ items, })); + // 발주처 에러 초기화 + clearFieldError("clientName"); toast.success("견적 정보가 불러와졌습니다."); }; @@ -449,7 +452,7 @@ export function OrderRegistration({