feat: implement standard pagination for org member list (#19802)
* feat: implement standard pagination for org member list * fix type error * i18n for pagination * add paginationMode * apply the change to PlatformManagedUsersTable * replace useInfiniteQuery with useQuery * fix type error * fix type error * fix type error * fix type error * update comment * remove optimistic update * minor changes * update usage on nuqs --------- Co-authored-by: Benny Joo <[email protected]>
This commit is contained in:
1 parent
861e3aa24f
commit
7eee2728a2
24 files changed
+403
-388
No files matched your search
@@ -7,14 +7,17 @@ export const useFetchMoreOnBottomReached = ({
|
||||
hasNextPage,
|
||||
fetchNextPage,
|
||||
isFetching,
|
||||
enabled = true,
|
||||
}: {
|
||||
tableContainerRef: React.RefObject<HTMLDivElement>;
|
||||
hasNextPage: boolean;
|
||||
fetchNextPage: () => void;
|
||||
isFetching: boolean;
|
||||
enabled?: boolean;
|
||||
}) => {
|
||||
const fetchMoreOnBottomReached = useCallback(
|
||||
(containerRefElement?: HTMLDivElement | null) => {
|
||||
if (!enabled) return;
|
||||
if (containerRefElement) {
|
||||
const { scrollHeight, scrollTop, clientHeight } = containerRefElement;
|
||||
if (scrollHeight - scrollTop - clientHeight < 300 && !isFetching && hasNextPage) {
|
||||
@@ -22,12 +25,13 @@ export const useFetchMoreOnBottomReached = ({
|
||||
}
|
||||
}
|
||||
},
|
||||
[fetchNextPage, isFetching]
|
||||
[fetchNextPage, isFetching, hasNextPage, enabled]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!enabled) return;
|
||||
fetchMoreOnBottomReached(tableContainerRef.current);
|
||||
}, [fetchMoreOnBottomReached, tableContainerRef]);
|
||||
}, [fetchMoreOnBottomReached, tableContainerRef, enabled]);
|
||||
|
||||
return fetchMoreOnBottomReached;
|
||||
};
|
||||
Reference in new issue
Block a user