diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/vendor-document-list/dolce-upload-service.ts | 1 | ||||
| -rw-r--r-- | lib/vendor-document-list/ship/enhanced-doc-table-toolbar-actions.tsx | 34 |
2 files changed, 29 insertions, 6 deletions
diff --git a/lib/vendor-document-list/dolce-upload-service.ts b/lib/vendor-document-list/dolce-upload-service.ts index 54672f33..d98a4c70 100644 --- a/lib/vendor-document-list/dolce-upload-service.ts +++ b/lib/vendor-document-list/dolce-upload-service.ts @@ -3,6 +3,7 @@ import db from "@/db/db" import { documents, revisions, documentAttachments, contracts, projects, vendors, issueStages } from "@/db/schema" import { eq, and, desc, sql, inArray, min } from "drizzle-orm" import { v4 as uuidv4 } from "uuid" +import path from "path" export interface DOLCEUploadResult { success: boolean diff --git a/lib/vendor-document-list/ship/enhanced-doc-table-toolbar-actions.tsx b/lib/vendor-document-list/ship/enhanced-doc-table-toolbar-actions.tsx index 508d8c91..c3b7251c 100644 --- a/lib/vendor-document-list/ship/enhanced-doc-table-toolbar-actions.tsx +++ b/lib/vendor-document-list/ship/enhanced-doc-table-toolbar-actions.tsx @@ -13,16 +13,37 @@ import { ImportFromDOLCEButton } from "./import-from-dolce-button" interface EnhancedDocTableToolbarActionsProps { table: Table<SimplifiedDocumentsView> projectType: "ship" | "plant" + contractId?: number } export function EnhancedDocTableToolbarActions({ table, projectType, + contractId, }: EnhancedDocTableToolbarActionsProps) { const [bulkUploadDialogOpen, setBulkUploadDialogOpen] = React.useState(false) // 현재 테이블의 모든 데이터 (필터링된 상태) const allDocuments = table.getFilteredRowModel().rows.map(row => row.original) + + // 모든 문서에서 고유한 contractId들 추출 + const contractIds = React.useMemo(() => { + const ids = new Set(allDocuments.map(doc => doc.contractId)) + return Array.from(ids) + }, [allDocuments]) + + // 주요 contractId (가장 많은 문서가 속한 계약) + const primaryContractId = React.useMemo(() => { + if (contractId) return contractId + if (contractIds.length === 0) return undefined + + const contractCounts = contractIds.map(id => ({ + id, + count: allDocuments.filter(doc => doc.contractId === id).length + })) + + return contractCounts.sort((a, b) => b.count - a.count)[0].id + }, [contractId, contractIds, allDocuments]) const handleSyncComplete = () => { // 동기화 완료 후 테이블 새로고침 @@ -77,12 +98,13 @@ export function EnhancedDocTableToolbarActions({ </Button> {/* Send to SHI 버튼 (공통) - 내부 → 외부로 보내기 */} - {/* <SendToSHIButton - contractId={selectedPackageId} - documents={allDocuments} - onSyncComplete={handleSyncComplete} - projectType={projectType} - /> */} + {primaryContractId && ( + <SendToSHIButton + contractId={primaryContractId} + onSyncComplete={handleSyncComplete} + projectType={projectType} + /> + )} </div> |
