"use client"; import type { Table as ReactTableType } from "@tanstack/react-table"; import { useRef } from "react"; import { DataTable, DataTableToolbar, DataTablePagination, useFetchMoreOnBottomReached, } from "@calcom/features/data-table"; export type DataTableWrapperProps = { testId?: string; bodyTestId?: string; table: ReactTableType; isPending: boolean; hasNextPage: boolean; fetchNextPage: () => void; isFetching: boolean; hideHeader?: boolean; variant?: "default" | "compact"; totalDBRowCount?: number; ToolbarLeft?: React.ReactNode; ToolbarRight?: React.ReactNode; className?: string; containerClassName?: string; children?: React.ReactNode; }; export function DataTableWrapper({ testId, bodyTestId, table, isPending, hasNextPage, fetchNextPage, isFetching, totalDBRowCount, variant, hideHeader, ToolbarLeft, ToolbarRight, className, containerClassName, children, }: DataTableWrapperProps) { const tableContainerRef = useRef(null); const fetchMoreOnBottomReached = useFetchMoreOnBottomReached({ tableContainerRef, hasNextPage, fetchNextPage, isFetching, }); return ( fetchMoreOnBottomReached(e.target as HTMLDivElement)}> {(ToolbarLeft || ToolbarRight) && (
{ToolbarLeft}
{ToolbarRight}
{children}
)} {totalDBRowCount && (
)}
); }