summaryrefslogtreecommitdiff
path: root/lib/vendor-investigation/table/investigation-table.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vendor-investigation/table/investigation-table.tsx')
-rw-r--r--lib/vendor-investigation/table/investigation-table.tsx56
1 files changed, 53 insertions, 3 deletions
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