Skip to content

feat(admin): add limit(50) + load-more to all admin collection listeners#213

Merged
hrx01-dev merged 1 commit into
hrx01-dev:mainfrom
kumudranjan6127-debug:fix/issue-209-admin-collection-limits
Jun 27, 2026
Merged

feat(admin): add limit(50) + load-more to all admin collection listeners#213
hrx01-dev merged 1 commit into
hrx01-dev:mainfrom
kumudranjan6127-debug:fix/issue-209-admin-collection-limits

Conversation

@kumudranjan6127-debug

@kumudranjan6127-debug kumudranjan6127-debug commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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 — added limit as firestoreLimit + query imports, PAGE_SIZE = 50 constant, extended CollectionState<T> with hasMore and loadMore, updated useCollectionData to query with firestoreLimit(pageLimit) and expose a loadMore function that increments the page cap by 50
  • src/admin/pages/Projects.tsx — added "Load more" button when projects.hasMore is true
  • src/admin/pages/ProjectUpdates.tsx — added "Load more" button when updates.hasMore is true
  • src/admin/pages/ProjectBilling.tsx — added "Load more" button when billing.hasMore is true
  • src/admin/pages/Clients.tsx — added "Load more" button when clients.hasMore is true
  • src/admin/pages/Messages.tsx — added "Load more" button when hasMore is true
  • src/admin/pages/Audit.tsx — added "Load more" button when auditLogs.hasMore is true
  • src/admin/pages/Settings.tsx — added "Load more" button when admins.hasMore is true

How 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

  • New Features
    • Added “Load more” controls across several admin lists and tables, including audit logs, clients, messages, billing, project updates, projects, and admin users.
    • Admin lists now support incremental loading so more records can be fetched on demand.
  • Bug Fixes
    • Improved list pagination behavior so longer datasets are easier to browse without reloading the page.

…ers — closes hrx01-dev#209

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown

@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.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Admin collection hooks now cap Firestore subscriptions at 50 documents, expose hasMore and loadMore, and admin collection pages render conditional “Load more” buttons to fetch additional records.

Changes

Admin collection pagination

Layer / File(s) Summary
Hook pagination
src/admin/hooks/useAdminData.ts
useCollectionData adds PAGE_SIZE, pageLimit, Firestore limit, and returns hasMore plus loadMore in CollectionState.
List page controls
src/admin/pages/Audit.tsx, src/admin/pages/Clients.tsx, src/admin/pages/Messages.tsx
Audit, Clients, and Messages add fragment wrappers where needed and render conditional “Load more” buttons tied to the shared pagination callbacks.
Table page controls
src/admin/pages/ProjectBilling.tsx, src/admin/pages/ProjectUpdates.tsx, src/admin/pages/Projects.tsx, src/admin/pages/Settings.tsx
ProjectBilling, ProjectUpdates, Projects, and Settings add conditional “Load more” buttons beneath their table views and keep the existing empty-state branches unchanged.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • hrx01-dev/Servio#170: This PR also extends the ProjectUpdates admin path and its Firestore-driven data flow, which is the same area now receiving pagination controls.
  • hrx01-dev/Servio#191: This PR changes src/admin/hooks/useAdminData.ts and src/admin/pages/ProjectUpdates.tsx, matching the hook-shape and page-wiring updates used here.

Suggested reviewers

  • hrx01-dev

Poem

/) /)

( •ᴥ•)
I hopped through lists and tables today,
And nibbled more pages along the way.
With Load more carrots, the burrows grew bright 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding a 50-item limit and load-more pagination to admin collection listeners.
Linked Issues check ✅ Passed The changes implement .limit(50), hasMore/loadMore state, and load-more UI for the admin collection views described in #209.
Out of Scope Changes check ✅ Passed No unrelated code changes are evident; the edits stay focused on pagination for admin collection listeners and their UI controls.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 03cf99f and d58c4f5.

📒 Files selected for processing (8)
  • src/admin/hooks/useAdminData.ts
  • src/admin/pages/Audit.tsx
  • src/admin/pages/Clients.tsx
  • src/admin/pages/Messages.tsx
  • src/admin/pages/ProjectBilling.tsx
  • src/admin/pages/ProjectUpdates.tsx
  • src/admin/pages/Projects.tsx
  • src/admin/pages/Settings.tsx

Comment thread src/admin/hooks/useAdminData.ts

@hrx01-dev hrx01-dev left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Approving this

@hrx01-dev hrx01-dev merged commit 33c9e54 into hrx01-dev:main Jun 27, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admin collections have no pagination — src/admin/hooks/useAdminData.ts:112-125

2 participants