diff --git a/src/components/quality/InspectionManagement/InspectionCreate.tsx b/src/components/quality/InspectionManagement/InspectionCreate.tsx index 95427ad3..374602c2 100644 --- a/src/components/quality/InspectionManagement/InspectionCreate.tsx +++ b/src/components/quality/InspectionManagement/InspectionCreate.tsx @@ -13,6 +13,7 @@ import { useState, useCallback, useMemo } from 'react'; import dynamic from 'next/dynamic'; import { useRouter } from 'next/navigation'; +import { useDaumPostcode } from '@/hooks/useDaumPostcode'; import { Plus, Trash2, ClipboardCheck } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; @@ -61,6 +62,20 @@ import { export function InspectionCreate() { const router = useRouter(); + // Daum 우편번호 서비스 + const { openPostcode } = useDaumPostcode({ + onComplete: (result) => { + setFormData(prev => ({ + ...prev, + scheduleInfo: { + ...prev.scheduleInfo, + sitePostalCode: result.zonecode, + siteAddress: result.address, + }, + })); + }, + }); + // 폼 상태 const [formData, setFormData] = useState({ qualityDocNumber: '', @@ -663,7 +678,7 @@ export function InspectionCreate() { onChange={(e) => updateNested('scheduleInfo', 'sitePostalCode', e.target.value)} className="w-28" /> - @@ -674,6 +689,7 @@ export function InspectionCreate() { value={formData.scheduleInfo.siteAddress} onChange={(e) => updateNested('scheduleInfo', 'siteAddress', e.target.value)} placeholder="주소 입력" + readOnly />
@@ -710,7 +726,7 @@ export function InspectionCreate() {
- ), [formData, orderSummary, orderGroups, updateField, updateNested, handleRemoveOrderItem, handleOpenInspectionInput, handleUpdateOrderItemField, orderModalOpen]); + ), [formData, orderSummary, orderGroups, updateField, updateNested, handleRemoveOrderItem, handleOpenInspectionInput, handleUpdateOrderItemField, orderModalOpen, openPostcode]); // 이미 선택된 수주 ID 목록 (orderId 기준, 중복 제거) const excludeOrderIds = useMemo( diff --git a/src/components/quality/InspectionManagement/InspectionDetail.tsx b/src/components/quality/InspectionManagement/InspectionDetail.tsx index 3c2a98b5..9f8c1c0e 100644 --- a/src/components/quality/InspectionManagement/InspectionDetail.tsx +++ b/src/components/quality/InspectionManagement/InspectionDetail.tsx @@ -13,6 +13,7 @@ import { useState, useCallback, useEffect, useMemo } from 'react'; import dynamic from 'next/dynamic'; import { useRouter, useSearchParams } from 'next/navigation'; +import { useDaumPostcode } from '@/hooks/useDaumPostcode'; import { FileText, PlayCircle, @@ -124,6 +125,20 @@ export function InspectionDetail({ id }: InspectionDetailProps) { const searchParams = useSearchParams(); const isEditModeParam = searchParams.get('mode') === 'edit'; + // Daum 우편번호 서비스 + const { openPostcode } = useDaumPostcode({ + onComplete: (result) => { + setFormData(prev => ({ + ...prev, + scheduleInfo: { + ...prev.scheduleInfo, + sitePostalCode: result.zonecode, + siteAddress: result.address, + }, + })); + }, + }); + // 상세 데이터 const [inspection, setInspection] = useState(null); const [isLoading, setIsLoading] = useState(true); @@ -1259,7 +1274,7 @@ export function InspectionDetail({ id }: InspectionDetailProps) { onChange={(e) => updateNested('scheduleInfo', 'sitePostalCode', e.target.value)} className="w-28" /> - @@ -1269,6 +1284,7 @@ export function InspectionDetail({ id }: InspectionDetailProps) { updateNested('scheduleInfo', 'siteAddress', e.target.value)} + readOnly />
@@ -1305,7 +1321,7 @@ export function InspectionDetail({ id }: InspectionDetailProps) {
); - }, [inspection, formData, orderSummary, orderGroups, updateField, updateNested, handleRemoveOrderItem, handleOpenInspectionInput, handleUpdateOrderItemField, orderModalOpen, renderFqcBadge, renderFqcProgressBar]); + }, [inspection, formData, orderSummary, orderGroups, updateField, updateNested, handleRemoveOrderItem, handleOpenInspectionInput, handleUpdateOrderItemField, orderModalOpen, renderFqcBadge, renderFqcProgressBar, openPostcode]); // ===== 모드 & Config ===== const mode = isEditMode ? 'edit' : 'view';