-
Notifications
You must be signed in to change notification settings - Fork 4
feat(SPV-1442) : Pagnation code handled by backend queries #1129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(SPV-1442) : Pagnation code handled by backend queries #1129
Conversation
feat(pagination): implement server-side pagination for contacts feat(pagination): add server-side pagination for paymails feat(pagination): implement server-side pagination for access keys feat(pagination): add server-side pagination for transactions feat(pagination): implement server-side pagination for xpubs feat(hooks): create usePagination hook for centralized pagination logic feat(hooks): implement useTable hook for table state management feat(utils): add query options with pagination support for API calls fix(pagination): ensure consistent page index conversion between UI and API feat(components): add pagination support to mobile data tables
Manual Testsℹ️ Remember to ask team members to perform manual tests and to assign |
feat(Pagination) : Update pagination types and constants feat(usePagination) : Common hook for useRoutePagination
| original: accessKey, | ||
| getValue: (key: string) => (key === 'status' ? accessKey.status : undefined), | ||
| } as Row<AccessKeysColumns>; | ||
| } as unknown as Row<AccessKey>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this necessary ? (The unknown casting)
| | ContactExtended | ||
| | PaymailExtended | ||
| | XpubExtended | ||
| | { id?: string; url?: string; status?: string }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider making a type for it to be consistent and to describe (by type name) what it is.
| useEffect(() => { | ||
| setExpandedItems([]); | ||
| setIsAllExpanded(false); | ||
| }, [table.getState().pagination.pageIndex, table.getState().pagination.pageSize]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could make a local variable (constant) for the pagination state.
| const total = manualPagination && totalRecords !== undefined ? totalRecords : table.getFilteredRowModel().rows.length; | ||
|
|
||
| // Track the current page size in local state to ensure the UI stays in sync | ||
| const [currentPageSize, setCurrentPageSize] = useState<number>(table.getState().pagination.pageSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also make a local const variable for table.getState().pagination
| // Initialize currentPageSize on mount and when table changes | ||
| useEffect(() => { | ||
| setCurrentPageSize(table.getState().pagination.pageSize); | ||
| }, [table]); | ||
|
|
||
| // Update local state when table pagination state changes | ||
| useEffect(() => { | ||
| // Always update the local state to match the table's page size | ||
| setCurrentPageSize(table.getState().pagination.pageSize); | ||
| }, [table.getState().pagination.pageSize]); | ||
|
|
||
| useEffect(() => { | ||
| setCurrentPageSize(table.getState().pagination.pageSize); | ||
| }, [table.getState().pagination]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be one useEffect with those three in one dependency list.
| export function useRoutePagination<TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string = string>( | ||
| routeID: ConstrainLiteral<TFrom, RouteIds<TRouter['routeTree']>>, | ||
| ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 👍
| // Local filter state for input field | ||
| const [filter, setFilter] = useState<string>(xpubId || ''); | ||
| const [debouncedFilter] = useDebounce(filter, 500); | ||
|
|
||
| // Update URL when the debounced filter changes | ||
| useEffect(() => { | ||
| navigate({ | ||
| search: (old) => ({ | ||
| ...old, | ||
| xpubId: debouncedFilter || undefined, | ||
| }), | ||
| replace: true, | ||
| }); | ||
| }, [debouncedFilter, navigate]); | ||
|
|
||
| // Sync filter input when URL xpubId changes | ||
| useEffect(() => { | ||
| setFilter(xpubId || ''); | ||
| }, [xpubId]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since my last PR, the Search component does "debouncing". I think, useSearchParam hook should be used here.
feat(pagination): implement server-side pagination for contacts
feat(pagination): add server-side pagination for paymails
feat(pagination): implement server-side pagination for access keys
feat(pagination): add server-side pagination for transactions
feat(pagination): implement server-side pagination for xpubs
feat(hooks): create usePagination hook for centralized pagination logic
feat(hooks): implement useTable hook for table state management
feat(utils): add query options with pagination support for API calls
fix(pagination): ensure consistent page index conversion between UI and API
feat(components): add pagination support to mobile data tables
Pull Request Checklist