MCPcopy
hub / github.com/midday-ai/midday / DataTable

Function DataTable

apps/dashboard/src/components/tables/vault/data-table.tsx:44–368  ·  view source on GitHub ↗
({ initialSettings }: Props)

Source from the content-addressed store, hash-verified

42};
43
44export function DataTable({ initialSettings }: Props) {
45 const trpc = useTRPC();
46 const queryClient = useQueryClient();
47 const { data: user } = useUserQuery();
48 const { filter, hasFilters } = useDocumentFilterParams();
49 const { setRowSelection, rowSelection } = useDocumentsStore();
50 const { setParams, params } = useDocumentParams();
51 const [, copy] = useCopyToClipboard();
52 const parentRef = useRef<HTMLDivElement>(null);
53
54 // Hide header on scroll
55 useScrollHeader(parentRef);
56
57 // Use unified table settings hook for column state management
58 const {
59 columnVisibility,
60 setColumnVisibility,
61 columnSizing,
62 setColumnSizing,
63 columnOrder,
64 setColumnOrder,
65 } = useTableSettings({
66 tableId: "vault",
67 initialSettings,
68 });
69
70 // Use the reusable table scroll hook
71 const tableScroll = useTableScroll({
72 useColumnWidths: true,
73 startFromColumn: 2, // Skip sticky columns: select, title
74 });
75
76 const {
77 data,
78 fetchNextPage,
79 hasNextPage,
80 refetch,
81 isFetching,
82 isFetchingNextPage,
83 } = useSuspenseInfiniteQuery(
84 trpc.documents.get.infiniteQueryOptions(
85 {
86 pageSize: 20,
87 ...filter,
88 },
89 {
90 getNextPageParam: ({ meta }) => meta?.cursor,
91 },
92 ),
93 );
94
95 const baseDocuments = useMemo(() => {
96 return data?.pages.flatMap((page) => page.data) ?? [];
97 }, [data]);
98
99 const debouncedEventHandler = useDebounceCallback(() => {
100 refetch();
101

Callers

nothing calls this directly

Calls 11

useUserQueryFunction · 0.90
useDocumentFilterParamsFunction · 0.90
useDocumentParamsFunction · 0.90
useScrollHeaderFunction · 0.90
useTableSettingsFunction · 0.90
useTableScrollFunction · 0.90
useRealtimeFunction · 0.90
toastFunction · 0.90
useTableDndFunction · 0.90
useStickyColumnsFunction · 0.90
useInfiniteScrollFunction · 0.90

Tested by

no test coverage detected