feat(admin): add limit(50) + load-more to all admin collection listeners#213
Conversation
…ers — closes hrx01-dev#209 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@kumudranjan6127-debug is attempting to deploy a commit to the hrx01-dev's projects Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughAdmin collection hooks now cap Firestore subscriptions at 50 documents, expose ChangesAdmin collection pagination
Sequence Diagram(s)sequenceDiagram
participant Projects
participant useCollectionData
participant Firestore
Projects->>useCollectionData: loadMore()
useCollectionData->>useCollectionData: pageLimit += PAGE_SIZE
useCollectionData->>Firestore: query(ref, firestoreLimit(pageLimit))
Firestore-->>useCollectionData: snapshot
useCollectionData-->>Projects: data + hasMore
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/admin/hooks/useAdminData.ts`:
- Around line 124-134: `useCollectionData()` is limiting Firestore results
before applying the UI-only sort, so pagination can return the wrong subset of
documents. Update the `useAdminData` query construction to include the same
ordering used by the `compare` sorter (for example via `query(...)` before
`firestoreLimit(pageLimit)`), or extend `useCollectionData` to accept an
order/query factory so `byCreatedDesc`, `byClientEmail`, and `byOrder` are
applied in Firestore rather than only in memory.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 53f776c9-5f8b-458b-935a-d3934406abab
📒 Files selected for processing (8)
src/admin/hooks/useAdminData.tssrc/admin/pages/Audit.tsxsrc/admin/pages/Clients.tsxsrc/admin/pages/Messages.tsxsrc/admin/pages/ProjectBilling.tsxsrc/admin/pages/ProjectUpdates.tsxsrc/admin/pages/Projects.tsxsrc/admin/pages/Settings.tsx
Closes #209
Problem
All 8 admin collection listeners loaded documents without any limit, which would cause unbounded Firestore reads and slow page loads as the database grows.
Changes
src/admin/hooks/useAdminData.ts— addedlimit as firestoreLimit+queryimports,PAGE_SIZE = 50constant, extendedCollectionState<T>withhasMoreandloadMore, updateduseCollectionDatato query withfirestoreLimit(pageLimit)and expose aloadMorefunction that increments the page cap by 50src/admin/pages/Projects.tsx— added "Load more" button whenprojects.hasMoreis truesrc/admin/pages/ProjectUpdates.tsx— added "Load more" button whenupdates.hasMoreis truesrc/admin/pages/ProjectBilling.tsx— added "Load more" button whenbilling.hasMoreis truesrc/admin/pages/Clients.tsx— added "Load more" button whenclients.hasMoreis truesrc/admin/pages/Messages.tsx— added "Load more" button whenhasMoreis truesrc/admin/pages/Audit.tsx— added "Load more" button whenauditLogs.hasMoreis truesrc/admin/pages/Settings.tsx— added "Load more" button whenadmins.hasMoreis trueHow it works
Each collection now starts with a cap of 50 documents. If Firestore returns exactly 50, a "Load more" button appears — clicking it raises the cap to 100, 150, and so on. No data is lost; the listener re-subscribes with the new limit.
Summary by CodeRabbit