From ef4c533ebacc2cdc97e518f30e9a9350004fcdfb Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Mon, 28 Apr 2025 02:13:30 +0000
Subject: ~20250428 작업사항
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../table/investigation-table.tsx                  | 56 ++++++++++++++++++++--
 1 file changed, 53 insertions(+), 3 deletions(-)

(limited to 'lib/vendor-investigation/table/investigation-table.tsx')

diff --git a/lib/vendor-investigation/table/investigation-table.tsx b/lib/vendor-investigation/table/investigation-table.tsx
index fa4e2ab8..56aa7962 100644
--- a/lib/vendor-investigation/table/investigation-table.tsx
+++ b/lib/vendor-investigation/table/investigation-table.tsx
@@ -21,6 +21,8 @@ import {
   PossibleItem
 } from "@/config/vendorInvestigationsColumnsConfig"
 import { UpdateVendorInvestigationSheet } from "./update-investigation-sheet"
+import { ItemsDrawer } from "./items-dialog"
+import { ContactsDialog } from "./contract-dialog"
 
 interface VendorsTableProps {
   promises: Promise<
@@ -71,18 +73,48 @@ export function VendorsInvestigationTable({ promises }: VendorsTableProps) {
       } as VendorInvestigationsViewWithContacts
     })
   }, [rawResponse.data])
+
+  console.log(transformedData)
   
   const pageCount = rawResponse.pageCount
 
+  // Add state for row actions
   const [rowAction, setRowAction] = React.useState<DataTableRowAction<VendorInvestigationsViewWithContacts> | null>(null)
   
+  // Add state for contacts dialog
+  const [contactsDialogOpen, setContactsDialogOpen] = React.useState(false)
+  const [selectedContacts, setSelectedContacts] = React.useState<ContactItem[]>([])
+  const [selectedContactInvestigationId, setSelectedContactInvestigationId] = React.useState<number | null>(null)
+  
+  // Add state for items drawer
+  const [itemsDrawerOpen, setItemsDrawerOpen] = React.useState(false)
+  const [selectedItems, setSelectedItems] = React.useState<PossibleItem[]>([])
+  const [selectedItemInvestigationId, setSelectedItemInvestigationId] = React.useState<number | null>(null)
+  
+  // Create handlers for opening the contacts dialog and items drawer
+  const openContactsModal = React.useCallback((investigationId: number, contacts: ContactItem[]) => {
+    setSelectedContactInvestigationId(investigationId)
+    setSelectedContacts(contacts || [])
+    setContactsDialogOpen(true)
+  }, [])
+  
+  const openItemsDrawer = React.useCallback((investigationId: number, items: PossibleItem[]) => {
+    setSelectedItemInvestigationId(investigationId)
+    setSelectedItems(items || [])
+    setItemsDrawerOpen(true)
+  }, [])
+  
   // Get router
   const router = useRouter()
   
-  // Call getColumns() with router injection
+  // Call getColumns() with all required functions
   const columns = React.useMemo(
-    () => getColumns({ setRowAction }),
-    [setRowAction, router]
+    () => getColumns({ 
+      setRowAction,
+      openContactsModal,
+      openItemsDrawer
+    }),
+    [setRowAction, openContactsModal, openItemsDrawer]
   )
   
   const filterFields: DataTableFilterField<VendorInvestigationsViewWithContacts>[] = [
@@ -123,11 +155,29 @@ export function VendorsInvestigationTable({ promises }: VendorsTableProps) {
           <VendorsTableToolbarActions table={table} />
         </DataTableAdvancedToolbar>
       </DataTable>
+
+      {/* Update Investigation Sheet */}
       <UpdateVendorInvestigationSheet
         open={rowAction?.type === "update"}
         onOpenChange={() => setRowAction(null)}
         investigation={rowAction?.row.original ?? null}
       />
+
+      {/* Contacts Dialog */}
+      <ContactsDialog
+        open={contactsDialogOpen}
+        onOpenChange={setContactsDialogOpen}
+        investigationId={selectedContactInvestigationId}
+        contacts={selectedContacts}
+      />
+
+      {/* Items Drawer */}
+      <ItemsDrawer
+        open={itemsDrawerOpen}
+        onOpenChange={setItemsDrawerOpen}
+        investigationId={selectedItemInvestigationId}
+        items={selectedItems}
+      />
     </>
   )
 }
\ No newline at end of file
-- 
cgit v1.2.3

