Skip to content

implemented sliding-window-pagination table#99

Merged
Utilitycoder merged 1 commit intoFundable-Protocol:mainfrom
chizzyedoka:feat/sliding-window-pagination-history-table
Mar 29, 2026
Merged

implemented sliding-window-pagination table#99
Utilitycoder merged 1 commit intoFundable-Protocol:mainfrom
chizzyedoka:feat/sliding-window-pagination-history-table

Conversation

@chizzyedoka
Copy link
Copy Markdown
Contributor

@chizzyedoka chizzyedoka commented Mar 29, 2026

fixed #48

Summary by CodeRabbit

  • Refactor
    • Standardized pagination controls across data tables with improved navigation interface.
    • Enhanced pagination behavior: page automatically resets to 1 when changing results per page, preventing invalid navigation states.

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 29, 2026

@chizzyedoka Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 29, 2026

📝 Walkthrough

Walkthrough

This PR implements a sliding window pagination system to enable navigation beyond the first 5 pages. It introduces a new SlidingPagination component and usePagination hook that compute pagination ranges with configurable sibling counts, and integrates them into HistoryTable and StreamsTable to replace inline pagination logic.

Changes

Cohort / File(s) Summary
Pagination Core
apps/web/src/hooks/use-pagination.ts, apps/web/src/components/molecules/SlidingPagination.tsx
New hook exports usePagination (memoized pagination range computation) and PaginationRangeItem type. New component renders "First"/"Last"/"Previous"/"Next" controls, page number links, and ellipsis markers; clamps page bounds and calls onPageChange on navigation.
History Table
apps/web/src/app/(overview)/history/page.tsx, apps/web/src/components/modules/history/HistoryTable.tsx
Removed unused HistoryTableSkeleton import and refactored pagination handlers to use updateHistoryParams for state sync. Replaced inline Pagination* UI components with single SlidingPagination component, removing manual button/link rendering and bound-checking logic.
Streams Table
apps/web/src/components/modules/payment-stream/StreamsTable.tsx
Replaced custom pagination UI built from @/components/ui/pagination with SlidingPagination; removed canPreviousPage/canNextPage computation and page-number link rendering loop. Updated layout to use flexbox structure with page size selector and pagination controls.

Sequence Diagram

sequenceDiagram
    actor User
    participant Page as history/page.tsx
    participant Table as HistoryTable
    participant Pagination as SlidingPagination
    participant Hook as usePagination
    participant Params as updateHistoryParams

    User->>Pagination: Click page number
    Pagination->>Pagination: navigate(targetPage)
    Pagination->>Table: onPageChange(targetPage)
    Table->>Page: onPageChange(targetPage)
    Page->>Params: updateHistoryParams({ page: targetPage })
    Params->>Page: Update URL & state
    Page->>Table: Re-render with new page
    Table->>Hook: usePagination({ currentPage, pageCount, siblingCount: 2 })
    Hook->>Hook: getPaginationRange()
    Hook->>Pagination: Return PaginationRangeItem[]
    Pagination->>Pagination: Render updated page links
    Pagination->>User: Display new pagination UI
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hops through pages now with glee,
No page five walls can stop a spree,
With ellipsis dots and siblings near,
First and last are always here,
Pagination slides, oh what a sight!

🚥 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 'implemented sliding-window-pagination table' clearly summarizes the main change—replacing pagination UI with a sliding-window component.
Linked Issues check ✅ Passed The PR fully implements issue #48 requirements: sliding-window pagination with current±2 pages, first/last page anchors, ellipsis, Previous/Next buttons, proper disabling, current page highlighting, and reusable component across HistoryTable and StreamsTable.
Out of Scope Changes check ✅ Passed All changes directly support the sliding-window pagination feature: new SlidingPagination component, use-pagination hook, and updates to HistoryTable and StreamsTable. No unrelated modifications found.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/web/src/app/`(overview)/history/page.tsx:
- Around line 252-255: The build fails because the onPageChange and
onLimitChange handlers call updateHistoryParams which is not defined or
imported; define or import the missing symbol and wire it to the component
state/update function used by this page (e.g., implement a local function
updateHistoryParams that updates the pagination/query params or import the
existing helper that does so), then replace the inline handlers to call that
defined function (keep the signatures used: updateHistoryParams({ page: nextPage
}) and updateHistoryParams({ page: 1, limit: nextLimit })) so the references in
onPageChange and onLimitChange resolve.

In `@apps/web/src/components/modules/payment-stream/StreamsTable.tsx`:
- Around line 211-215: The JSX has a mismatched tag and missing import: replace
the stray closing </div> with a closing </PaginationContent> to correctly match
the opening PaginationContent element and ensure PaginationContent is imported
at top of the file (or use the intended component name if different); confirm
the inner div that displays "Page {page} of {pageCount}" remains as a child of
PaginationContent and that the variables page and pageCount are in scope.
🪄 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

Run ID: ca837f78-e133-4cbc-8531-1aa8f0586a14

📥 Commits

Reviewing files that changed from the base of the PR and between f63af83 and ec33771.

📒 Files selected for processing (5)
  • apps/web/src/app/(overview)/history/page.tsx
  • apps/web/src/components/modules/history/HistoryTable.tsx
  • apps/web/src/components/modules/payment-stream/StreamsTable.tsx
  • apps/web/src/components/molecules/SlidingPagination.tsx
  • apps/web/src/hooks/use-pagination.ts

Comment on lines +252 to +255
onPageChange={(nextPage) => updateHistoryParams({ page: nextPage })}
onLimitChange={(nextLimit) =>
updateHistoryParams({ page: 1, limit: nextLimit })
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Undefined handler causes a compile-time failure.

Line 252 and Line 254 call updateHistoryParams, but that symbol is not defined/imported in this file. This blocks the build.

💡 Minimal fix
-                            onPageChange={(nextPage) => updateHistoryParams({ page: nextPage })}
-                            onLimitChange={(nextLimit) =>
-                                updateHistoryParams({ page: 1, limit: nextLimit })
-                            }
+                            onPageChange={(nextPage) => setPage(nextPage)}
+                            onLimitChange={(nextLimit) => {
+                                setPage(1);
+                                setLimit(nextLimit);
+                            }}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web/src/app/`(overview)/history/page.tsx around lines 252 - 255, The
build fails because the onPageChange and onLimitChange handlers call
updateHistoryParams which is not defined or imported; define or import the
missing symbol and wire it to the component state/update function used by this
page (e.g., implement a local function updateHistoryParams that updates the
pagination/query params or import the existing helper that does so), then
replace the inline handlers to call that defined function (keep the signatures
used: updateHistoryParams({ page: nextPage }) and updateHistoryParams({ page: 1,
limit: nextLimit })) so the references in onPageChange and onLimitChange
resolve.

Comment on lines 211 to +215
<PaginationContent className="hidden lg:flex flex-col sm:flex-row sm:space-y-0 sm:space-x-6 lg:space-x-8">
<div className="flex w-[100px] items-center justify-center text-sm font-medium text-zinc-300" aria-live="polite" aria-atomic="true">
Page {page} of {pageCount}
</div>
</PaginationContent>

<PaginationContent className="gap-2">
<PaginationPrevious
onClick={() => updatePage(page - 1)}
disabled={!canPreviousPage}
/>
{Array.from(
{ length: pageCount > 3 ? 3 : pageCount },
(_, index) => (
<PaginationLink
key={`streams-pagination-${index}`}
onClick={() => updatePage(index + 1)}
isActive={page === index + 1}
>
{index + 1}
</PaginationLink>
)
)}

{pageCount > 3 ? (
<PaginationContent className="flex items-center space-x-4">
<PaginationEllipsis />
<PaginationLink
onClick={() => updatePage(pageCount)}
isActive={page === pageCount}
>
{pageCount}
</PaginationLink>
</PaginationContent>
) : null}

<PaginationNext
onClick={() => updatePage(page + 1)}
disabled={!canNextPage}
/>
</PaginationContent>
</Pagination>
</div>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Broken JSX structure in pagination summary block.

Line 211 opens PaginationContent, but Line 215 closes </div>. This is a parser error. Also, PaginationContent isn’t imported, so this block won’t compile as written.

💡 Suggested fix
-                    <PaginationContent className="hidden lg:flex flex-col sm:flex-row sm:space-y-0 sm:space-x-6 lg:space-x-8">
+                    <div className="hidden lg:flex flex-col sm:flex-row sm:space-y-0 sm:space-x-6 lg:space-x-8">
                         <div className="flex w-[100px] items-center justify-center text-sm font-medium text-zinc-300" aria-live="polite" aria-atomic="true">
                             Page {page} of {pageCount}
                         </div>
-                    </div>
+                    </div>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<PaginationContent className="hidden lg:flex flex-col sm:flex-row sm:space-y-0 sm:space-x-6 lg:space-x-8">
<div className="flex w-[100px] items-center justify-center text-sm font-medium text-zinc-300" aria-live="polite" aria-atomic="true">
Page {page} of {pageCount}
</div>
</PaginationContent>
<PaginationContent className="gap-2">
<PaginationPrevious
onClick={() => updatePage(page - 1)}
disabled={!canPreviousPage}
/>
{Array.from(
{ length: pageCount > 3 ? 3 : pageCount },
(_, index) => (
<PaginationLink
key={`streams-pagination-${index}`}
onClick={() => updatePage(index + 1)}
isActive={page === index + 1}
>
{index + 1}
</PaginationLink>
)
)}
{pageCount > 3 ? (
<PaginationContent className="flex items-center space-x-4">
<PaginationEllipsis />
<PaginationLink
onClick={() => updatePage(pageCount)}
isActive={page === pageCount}
>
{pageCount}
</PaginationLink>
</PaginationContent>
) : null}
<PaginationNext
onClick={() => updatePage(page + 1)}
disabled={!canNextPage}
/>
</PaginationContent>
</Pagination>
</div>
<div className="hidden lg:flex flex-col sm:flex-row sm:space-y-0 sm:space-x-6 lg:space-x-8">
<div className="flex w-[100px] items-center justify-center text-sm font-medium text-zinc-300" aria-live="polite" aria-atomic="true">
Page {page} of {pageCount}
</div>
</div>
🧰 Tools
🪛 Biome (2.4.9)

[error] 211-211: Expected corresponding JSX closing tag for 'PaginationContent'.

(parse)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web/src/components/modules/payment-stream/StreamsTable.tsx` around lines
211 - 215, The JSX has a mismatched tag and missing import: replace the stray
closing </div> with a closing </PaginationContent> to correctly match the
opening PaginationContent element and ensure PaginationContent is imported at
top of the file (or use the intended component name if different); confirm the
inner div that displays "Page {page} of {pageCount}" remains as a child of
PaginationContent and that the variables page and pageCount are in scope.

@pragmaticAweds
Copy link
Copy Markdown
Contributor

Hi @chizzyedoka,

Kindly add screen record of your implementation, it is required.

Copy link
Copy Markdown
Contributor

@pragmaticAweds pragmaticAweds left a comment

Choose a reason for hiding this comment

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

Hi @chizzyedoka,

Kindly add screen record of your implementation, it is required.

@chizzyedoka
Copy link
Copy Markdown
Contributor Author

Noted

@pragmaticAweds
Copy link
Copy Markdown
Contributor

Thanks chief, I am waiting.

@Utilitycoder Utilitycoder merged commit 6e2f2ce into Fundable-Protocol:main Mar 29, 2026
1 check 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.

Fix Pagination to Support Navigation Beyond First 5 Pages in History Table

3 participants