diff --git a/frontend/lib/utils/buttonActions.ts b/frontend/lib/utils/buttonActions.ts index 58a3b288..c56a9dd4 100644 --- a/frontend/lib/utils/buttonActions.ts +++ b/frontend/lib/utils/buttonActions.ts @@ -543,9 +543,25 @@ export class ButtonActionExecutor { // 🆕 modalDataStore에서 누적된 모든 테이블 데이터 가져오기 // (여러 단계 모달에서 전달된 데이터 접근용) - const modalDataStore = typeof window !== 'undefined' - ? (window as any).__modalDataRegistry || {} - : {}; + let modalDataStoreRegistry: Record = {}; + if (typeof window !== 'undefined') { + try { + // Zustand store에서 데이터 가져오기 + const { useModalDataStore } = await import('@/stores/modalDataStore'); + modalDataStoreRegistry = useModalDataStore.getState().dataRegistry; + } catch (error) { + console.warn("⚠️ modalDataStore 로드 실패:", error); + } + } + + // 각 테이블의 첫 번째 항목을 modalDataStore로 변환 + const modalDataStore: Record = {}; + Object.entries(modalDataStoreRegistry).forEach(([key, items]) => { + if (Array.isArray(items) && items.length > 0) { + // ModalDataItem[] → originalData 추출 + modalDataStore[key] = items.map(item => item.originalData || item); + } + }); console.log(`🔍 [handleBatchSave] 부모 데이터:`, { hasParentData: Object.keys(parentData).length > 0, @@ -554,6 +570,12 @@ export class ButtonActionExecutor { selectedRowsData, originalData, modalDataStoreKeys: Object.keys(modalDataStore), + modalDataStoreDetails: Object.fromEntries( + Object.entries(modalDataStore).map(([key, data]) => [ + key, + { count: Array.isArray(data) ? data.length : 1, hasData: !!data } + ]) + ), }); // 각 SelectedItemsDetailInput 컴포넌트의 데이터 처리