From 7827446e923e725db30ce2e849f5698d6bcfdeea Mon Sep 17 00:00:00 2001
From: joonhoekim <26rote@gmail.com>
Date: Tue, 4 Nov 2025 14:37:22 +0900
Subject: (김준회) bulk b4 upload 프로젝트 목록 문제(페이지네이션 내부 데이터로
 한정되는 문제) 및 이모지 제거, change_logs 미반영 오류 처리
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../ship/enhanced-doc-table-toolbar-actions.tsx    | 34 +++++++++++++++++-----
 1 file changed, 26 insertions(+), 8 deletions(-)

(limited to 'lib/vendor-document-list/ship/enhanced-doc-table-toolbar-actions.tsx')

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 94252db5..846eb5b2 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,20 +13,28 @@ import { SendToSHIButton } from "./send-to-shi-button"
 import { ImportFromDOLCEButton } from "./import-from-dolce-button"
 import { BulkB4UploadDialog } from "./bulk-b4-upload-dialog"
 
+interface ProjectCodeStat {
+  code: string
+  count: number
+  projectId: number | null
+}
+
 interface EnhancedDocTableToolbarActionsProps {
   table: Table<SimplifiedDocumentsView>
   projectType: "ship" | "plant"
   b4: boolean
+  projectCodeStats?: ProjectCodeStat[]
 }
 
 export function EnhancedDocTableToolbarActions({
   table,
   projectType,
-  b4
+  b4,
+  projectCodeStats = []
 }: EnhancedDocTableToolbarActionsProps) {
   const [bulkUploadDialogOpen, setBulkUploadDialogOpen] = React.useState(false)
 
-  // 🔥 메모이제이션으로 불필요한 재계산 방지
+  // 메모이제이션으로 불필요한 재계산 방지
   const allDocuments = React.useMemo(() => {
     return table.getFilteredRowModel().rows.map(row => row.original)
   }, [
@@ -35,20 +43,30 @@ export function EnhancedDocTableToolbarActions({
     table.getState().globalFilter, // 전역 필터가 변경될 때만 재계산
   ])
 
-  // 🔥 projectIds 메모이제이션 (ImportFromDOLCEButton에서 중복 계산 방지)
+  // projectIds 메모이제이션 (ImportFromDOLCEButton에서 중복 계산 방지)
   const projectIds = React.useMemo(() => {
     const uniqueIds = [...new Set(allDocuments.map(doc => doc.projectId).filter(Boolean))]
     return uniqueIds.sort()
   }, [allDocuments])
 
-  // 🔥 핸들러들을 useCallback으로 메모이제이션
+  // 프로젝트 옵션 생성 (전체 프로젝트 목록)
+  const projectOptions = React.useMemo(() => {
+    return projectCodeStats
+      .filter(stat => stat.code !== 'Unknown' && stat.projectId)
+      .map(stat => ({
+        id: String(stat.projectId),
+        code: stat.code
+      }))
+  }, [projectCodeStats])
+
+  // 핸들러들을 useCallback으로 메모이제이션
   const handleSyncComplete = React.useCallback(() => {
     table.resetRowSelection()
   }, [table])
 
   const handleDocumentAdded = React.useCallback(() => {
     table.resetRowSelection()
-    // 🔥 강제 새로고침 대신 더 효율적인 방법 사용
+    // 강제 새로고침 대신 더 효율적인 방법 사용
     setTimeout(() => {
       // 상태 업데이트만으로 충분한 경우가 많음
       window.location.reload()
@@ -62,7 +80,7 @@ export function EnhancedDocTableToolbarActions({
     }, 500)
   }, [table])
 
-  // 🔥 Export 핸들러 메모이제이션
+  // Export 핸들러 메모이제이션
   const handleExport = React.useCallback(() => {
     exportTableToExcel(table, {
       filename: "Document-list",
@@ -76,7 +94,7 @@ export function EnhancedDocTableToolbarActions({
         {/* SHIP: DOLCE에서 목록 가져오기 */}
         <ImportFromDOLCEButton
           allDocuments={allDocuments}
-          projectIds={projectIds} // 🔥 미리 계산된 projectIds 전달
+          projectIds={projectIds} // 미리 계산된 projectIds 전달
           onImportComplete={handleImportComplete}
         />
 
@@ -117,7 +135,7 @@ export function EnhancedDocTableToolbarActions({
         <BulkB4UploadDialog
           open={bulkUploadDialogOpen}
           onOpenChange={setBulkUploadDialogOpen}
-          allDocuments={allDocuments}
+          projectOptions={projectOptions}
         />
       )}
     </>
-- 
cgit v1.2.3

