diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-10-13 00:22:54 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-10-13 00:22:54 +0000 |
| commit | 89274bffa596ffdfc4275fb8d11cdb02ff9a2d02 (patch) | |
| tree | 8597ef56c39ac4913eacdb0fc663b5fe80de127b /lib/techsales-rfq/table/detail-table/vendor-contact-selection-dialog.tsx | |
| parent | 00092099271ff743ac195511c03994e80f91a2e9 (diff) | |
(최겸) 기술영업 import 수정 2
Diffstat (limited to 'lib/techsales-rfq/table/detail-table/vendor-contact-selection-dialog.tsx')
| -rw-r--r-- | lib/techsales-rfq/table/detail-table/vendor-contact-selection-dialog.tsx | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/lib/techsales-rfq/table/detail-table/vendor-contact-selection-dialog.tsx b/lib/techsales-rfq/table/detail-table/vendor-contact-selection-dialog.tsx index 031f4aa2..d83394bb 100644 --- a/lib/techsales-rfq/table/detail-table/vendor-contact-selection-dialog.tsx +++ b/lib/techsales-rfq/table/detail-table/vendor-contact-selection-dialog.tsx @@ -25,6 +25,7 @@ interface VendorContact { contactEmail: string
contactPhone: string | null
isPrimary: boolean
+ isSelectedForRfq?: boolean // RFQ의 아이템과 연결되어 있는지 여부
}
interface VendorWithContacts {
@@ -47,6 +48,7 @@ interface VendorContactSelectionDialogProps { open: boolean
onOpenChange: (open: boolean) => void
vendorIds: number[]
+ rfqId?: number // RFQ ID 추가
onSendRfq: (selectedContacts: SelectedContact[]) => Promise<void>
}
@@ -54,6 +56,7 @@ export function VendorContactSelectionDialog({ open,
onOpenChange,
vendorIds,
+ rfqId,
onSendRfq
}: VendorContactSelectionDialogProps) {
const [vendorsWithContacts, setVendorsWithContacts] = useState<Record<number, VendorWithContacts>>({})
@@ -80,38 +83,41 @@ export function VendorContactSelectionDialog({ const loadVendorsContacts = useCallback(async () => {
try {
setIsLoading(true)
- const { getTechVendorsContacts } = await import("@/lib/techsales-rfq/service")
-
- const result = await getTechVendorsContacts(vendorIds)
-
+ const { getTechVendorsContactsWithPossibleItems } = await import("@/lib/techsales-rfq/service")
+
+ const result = await getTechVendorsContactsWithPossibleItems(vendorIds, rfqId)
+
if (result.error) {
toast.error(result.error)
return
}
-
+
setVendorsWithContacts(result.data)
-
- // 기본 선택: 모든 contact 선택
+
+ // 기본 선택: techSalesContactPossibleItems 테이블을 기준으로 선택
const defaultSelected: SelectedContact[] = []
Object.values(result.data).forEach(vendorData => {
vendorData.contacts.forEach(contact => {
- defaultSelected.push({
- vendorId: vendorData.vendor.id,
- contactId: contact.id,
- contactEmail: contact.contactEmail,
- contactName: contact.contactName
- })
+ // 해당 담당자가 선택된 아이템과 연결되어 있다면 우선 선택
+ if (contact.isSelectedForRfq) {
+ defaultSelected.push({
+ vendorId: vendorData.vendor.id,
+ contactId: contact.id,
+ contactEmail: contact.contactEmail,
+ contactName: contact.contactName
+ })
+ }
})
})
setSelectedContacts(defaultSelected)
-
+
} catch (error) {
console.error("벤더 contact 조회 오류:", error)
toast.error("벤더 연락처를 불러오는 중 오류가 발생했습니다")
} finally {
setIsLoading(false)
}
- }, [vendorIds])
+ }, [vendorIds, rfqId])
// contact 선택/해제 핸들러
const handleContactToggle = (vendorId: number, contact: VendorContact) => {
@@ -201,7 +207,7 @@ export function VendorContactSelectionDialog({ <DialogHeader>
<DialogTitle>RFQ 발송 대상 선택</DialogTitle>
<DialogDescription>
- 각 벤더의 연락처를 선택하여 RFQ를 발송하세요. 기본적으로 모든 연락처가 선택되어 있습니다.
+ RFQ에 포함된 자재와 연결된 담당자들이 우선 선택됩니다. 해당 벤더에 연결된 담당자가 없다면 수동으로 선택해주세요.
</DialogDescription>
</DialogHeader>
@@ -227,7 +233,8 @@ export function VendorContactSelectionDialog({ ) : (
Object.entries(vendorsWithContacts).map(([vendorId, vendorData]) => {
const selectionState = getVendorSelectionState(Number(vendorId), vendorData)
-
+ const hasSelectedContacts = vendorData.contacts.some(contact => contact.isSelectedForRfq)
+
return (
<div key={vendorId} className="border rounded-lg p-4">
<div className="flex items-center justify-between mb-3">
@@ -251,6 +258,11 @@ export function VendorContactSelectionDialog({ 코드: {vendorData.vendor.vendorCode}
</p>
)}
+ {!hasSelectedContacts && (
+ <p className="text-sm text-orange-600">
+ ※ 해당 벤더의 담당자가 RFQ 자재와 연결되지 않았습니다. 수동으로 선택해주세요.
+ </p>
+ )}
</div>
</div>
<Badge variant="outline">
|
