This repository has been archived on 2026-11-23. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
hope-events/frontend/src/components/shared/Pager.tsx
T
joshuaandClaude Opus 5.5 4c066e67d9 Pagination and search on long lists (1.50.1)
Audit log: search (person, target, IP), role filter, every action in the
filter, inclusive To date. Data requests: search and paging (was cut at
200). Webhook deliveries: status filter and Load older. Supervisor Payments
loads only what it needs (unpaid registrations, recent/today/donation
payments, a person's own for refunds) instead of everything.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ls1vMdg2GYqbnKZmPaX1ot
2026-10-29 06:53:54 +02:00

29 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client";
/**
* "21–40 of 312 · ← Prev · Next →" under a server-paged list. Hidden when everything fits on
* one page.
*/
export function Pager({ page, pageSize, total, onPage, busy }: {
page: number;
pageSize: number;
total: number;
onPage: (page: number) => void;
busy?: boolean;
}) {
const pages = Math.max(1, Math.ceil(total / pageSize));
if (pages <= 1) return null;
const btn = "px-2 py-1 rounded bg-gray-100 hover:bg-gray-200 disabled:opacity-40";
return (
<nav aria-label="Pages" className="flex items-center justify-between mt-4 text-sm">
<span className="text-gray-500">
{(page - 1) * pageSize + 1}–{Math.min(page * pageSize, total)} of {total} · page {page} of {pages}
</span>
<div className="flex gap-1">
<button className={btn} disabled={page <= 1 || busy} onClick={() => onPage(page - 1)}>← Prev</button>
<button className={btn} disabled={page >= pages || busy} onClick={() => onPage(page + 1)}>Next →</button>
</div>
</nav>
);
}