refactor: make DataTableProvider framework-agnostic by requiring tableIdentifier (#24513)
* refactor: make DataTableProvider framework-agnostic by requiring tableIdentifier - Remove Next.js usePathname dependency from DataTableProvider - Make tableIdentifier a required prop instead of optional - Update all usages to provide explicit tableIdentifier values - This makes DataTableProvider usable in non-Next.js contexts Co-Authored-By: [email protected] <[email protected]> * refactor: use usePathname at usage sites instead of hardcoding tableIdentifier - Add validation in DataTableProvider for empty/nullish tableIdentifier - Use usePathname() in Next.js apps to pass pathname as tableIdentifier - Use descriptive identifiers for non-Next.js package components - This keeps DataTableProvider framework-agnostic while allowing Next.js apps to use pathname Co-Authored-By: [email protected] <[email protected]> * use pathname instead of hard-coded identifiers * change type of tableIdentifier * simplify --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
4ac8a51bc2
commit
09ddbe886f
14 files changed
+67
-42
No files matched your search
@@ -3,6 +3,7 @@
|
||||
import { keepPreviousData } from "@tanstack/react-query";
|
||||
import { getCoreRowModel, getSortedRowModel, useReactTable, type ColumnDef } from "@tanstack/react-table";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { useQueryState, parseAsBoolean } from "nuqs";
|
||||
import { useMemo, useReducer, useState } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
@@ -126,8 +127,10 @@ export type UserListTableProps = {
|
||||
};
|
||||
|
||||
export function UserListTable(props: UserListTableProps) {
|
||||
const pathname = usePathname();
|
||||
if (!pathname) return null;
|
||||
return (
|
||||
<DataTableProvider useSegments={useSegments} defaultPageSize={25}>
|
||||
<DataTableProvider tableIdentifier={pathname} useSegments={useSegments} defaultPageSize={25}>
|
||||
<UserListTableContent {...props} />
|
||||
</DataTableProvider>
|
||||
);
|
||||
@@ -168,8 +171,6 @@ function UserListTableContent({
|
||||
}
|
||||
);
|
||||
|
||||
// TODO (SEAN): Make Column filters a trpc query param so we can fetch serverside even if the data is not loaded
|
||||
const totalRowCount = data?.meta?.totalRowCount ?? 0;
|
||||
const adminOrOwner = checkAdminOrOwner(org?.user?.role);
|
||||
|
||||
//we must flatten the array of arrays from the useInfiniteQuery hook
|
||||
@@ -514,7 +515,7 @@ function UserListTableContent({
|
||||
value: team.name,
|
||||
}))
|
||||
);
|
||||
default:
|
||||
default: {
|
||||
const attribute = facetedTeamValues.attributes.find((attr) => attr.id === columnId);
|
||||
if (attribute) {
|
||||
return convertFacetedValuesToMap(
|
||||
@@ -525,6 +526,7 @@ function UserListTableContent({
|
||||
);
|
||||
}
|
||||
return new Map();
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Map();
|
||||
|
||||
Reference in new issue
Block a user