Skip to content

Pagination Implementation - #22

Merged
OmarLawaty merged 7 commits into
devfrom
feat/optimizations/pagination
Sep 6, 2026
Merged

OmarLawaty merged 7 commits into
devfrom
feat/optimizations/pagination

Conversation

@OmarLawaty

Copy link
Copy Markdown
Member

No description provided.

@OmarLawaty
OmarLawaty requested a lite review from Copilot September 6, 2026 02:27
@OmarLawaty OmarLawaty self-assigned this Sep 6, 2026
@OmarLawaty OmarLawaty added enhancement New feature or request feature labels Sep 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

It introduces confirmed runtime/typing issues (a circular barrel import in DataTable and overridable page params in multiple infinite query hooks) that can break pagination and module resolution.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR replaces the existing “fetch-all” list queries for users/products/orders/discounts with paginated infinite queries, and wires the UI to support infinite scrolling (including SSR prefetch hydration) using a new IntersectionObserver-based trigger.

Changes:

  • Replace use*Query list hooks with use*InfiniteQuery hooks returning Pagination<T> and support SSR prefetchInfiniteQuery.
  • Add infinite-scroll infrastructure (useIsInView, InfiniteScrollTrigger) and extend DataTable to optionally load more rows.
  • Update list pages, modals, and mutations to use the new infinite query hooks and invalidation functions.
File summaries
File Description
src/hooks/users/useUsersQuery.ts Removed non-paginated users list query hook.
src/hooks/users/useUsersInfiniteQuery.ts Added paginated infinite users query hook.
src/hooks/users/useUpdateUserMutation.ts Updated invalidation import to target infinite users queries.
src/hooks/users/useCreateUserMutation.ts Updated invalidation import to target infinite users queries.
src/hooks/users/index.ts Switched barrel export to useUsersInfiniteQuery.
src/hooks/useIsInView.ts Added IntersectionObserver hook used by infinite scroll trigger.
src/hooks/products/useUpdateProductMutation.ts Updated invalidation import to target infinite products queries.
src/hooks/products/useRemoveProductMutation.ts Updated invalidation import to target infinite products queries.
src/hooks/products/useProductsQuery.ts Removed non-paginated products list query hook.
src/hooks/products/useProductsInfiniteQuery.ts Added paginated infinite products query hook.
src/hooks/products/useAddProductMutation.ts Updated invalidation import to target infinite products queries.
src/hooks/products/index.ts Switched barrel export to useProductsInfiniteQuery.
src/hooks/orders/useUpdateShippingMutation.ts Updated invalidation import to target infinite orders queries.
src/hooks/orders/useUpdateOrderStatusMutation.ts Updated invalidation import to target infinite orders queries.
src/hooks/orders/useUpdateOrderPaymentStatusMutation.ts Updated invalidation import to target infinite orders queries.
src/hooks/orders/useUpdateOrderItemMutation.ts Updated invalidation import to target infinite orders queries.
src/hooks/orders/useRestockInventoryMutation.ts Updated invalidation import to target infinite orders queries.
src/hooks/orders/useRemoveOrderItemMutation.ts Updated invalidation import to target infinite orders queries.
src/hooks/orders/useOrdersQuery.ts Removed non-paginated orders list query hook.
src/hooks/orders/useOrdersInfiniteQuery.ts Added paginated infinite orders query hook.
src/hooks/orders/useCreateOrderMutation.ts Updated invalidation import to target infinite orders queries.
src/hooks/orders/useAddOrderItemMutation.ts Updated invalidation import to target infinite orders queries.
src/hooks/orders/index.ts Switched barrel export to useOrdersInfiniteQuery.
src/hooks/index.ts Exported new useIsInView hook from hooks barrel.
src/hooks/discounts/useUpdateDiscountMutation.ts Updated invalidation import to target infinite discounts queries.
src/hooks/discounts/useRemoveDiscountMutation.ts Updated invalidation import to target infinite discounts queries.
src/hooks/discounts/useDiscountsQuery.ts Removed non-paginated discounts list query hook.
src/hooks/discounts/useDiscountsInfiniteQuery.ts Added paginated infinite discounts query hook.
src/hooks/discounts/useAddDiscountMutation.ts Updated invalidation import to target infinite discounts queries.
src/hooks/discounts/index.ts Switched barrel export to useDiscountsInfiniteQuery.
src/components/users/UsersList.tsx Updated users list to flatten infinite pages and pass load-more props to DataTable.
src/components/users/UserSelectModal.tsx Updated modal to use infinite users query + scroll container trigger for load more.
src/components/ui/index.ts Re-exported table UI module from UI barrel.
src/components/products/ProductVariantsModal.tsx Updated modal to use infinite products query + scroll container trigger for load more.
src/components/products/ProductsList.tsx Updated products list to flatten infinite pages and pass load-more props to DataTable.
src/components/orders/OrdersList.tsx Updated orders list to flatten infinite pages and pass load-more props to DataTable.
src/components/InfiniteScrollTrigger.tsx Added reusable trigger component to call onLoadMore when sentinel enters view.
src/components/index.ts Exported InfiniteScrollTrigger from components barrel.
src/components/discounts/DiscountsList.tsx Updated discounts list to flatten infinite pages and pass load-more props to DataTable.
src/components/DataTable.tsx Added optional infinite-scroll props and renders trigger below the table.
src/app/(hydration)/(base)/users/page.tsx Switched SSR prefetch to prefetchInfiniteQuery for users.
src/app/(hydration)/(base)/orders/page.tsx Switched SSR prefetch to prefetchInfiniteQuery for orders.
src/app/(hydration)/(base)/discounts/page.tsx Switched SSR prefetch to prefetchInfiniteQuery for discounts.
src/app/(hydration)/(base)/(store)/products/page.tsx Switched SSR prefetch to prefetchInfiniteQuery for products.
src/app/(hydration)/(base)/(store)/featured-variants/page.tsx Switched SSR prefetch to prefetchInfiniteQuery for products (used on featured variants page).
src/api/backend/types.ts Added Pagination<T> and PaginationParams backend types.
Review details
  • Files reviewed: 46/46 changed files
  • Comments generated: 6
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/components/DataTable.tsx Outdated
Comment thread src/hooks/discounts/useDiscountsInfiniteQuery.ts Outdated
Comment thread src/hooks/orders/useOrdersInfiniteQuery.ts Outdated
Comment thread src/hooks/products/useProductsInfiniteQuery.ts Outdated
Comment thread src/hooks/users/useUsersInfiniteQuery.ts Outdated
Comment thread src/hooks/useIsInView.ts
@OmarLawaty
OmarLawaty merged commit beb9614 into dev Sep 6, 2026
2 checks passed
@OmarLawaty
OmarLawaty deleted the feat/optimizations/pagination branch September 6, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants