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({