From ef4c533ebacc2cdc97e518f30e9a9350004fcdfb Mon Sep 17 00:00:00 2001 From: dujinkim 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 | null>(null) + // Add state for contacts dialog + const [contactsDialogOpen, setContactsDialogOpen] = React.useState(false) + const [selectedContacts, setSelectedContacts] = React.useState([]) + const [selectedContactInvestigationId, setSelectedContactInvestigationId] = React.useState(null) + + // Add state for items drawer + const [itemsDrawerOpen, setItemsDrawerOpen] = React.useState(false) + const [selectedItems, setSelectedItems] = React.useState([]) + const [selectedItemInvestigationId, setSelectedItemInvestigationId] = React.useState(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[] = [ @@ -123,11 +155,29 @@ export function VendorsInvestigationTable({ promises }: VendorsTableProps) { + + {/* Update Investigation Sheet */} setRowAction(null)} investigation={rowAction?.row.original ?? null} /> + + {/* Contacts Dialog */} + + + {/* Items Drawer */} + ) } \ No newline at end of file -- cgit v1.2.3