Files
fintrack/components/transactions/transaction-pagination.tsx

51 lines
1.1 KiB
TypeScript

"use client";
import { Button } from "@/components/ui/button";
interface TransactionPaginationProps {
page: number;
pageSize: number;
total: number;
hasMore: boolean;
onPageChange: (page: number) => void;
}
export function TransactionPagination({
page,
pageSize,
total,
hasMore,
onPageChange,
}: TransactionPaginationProps) {
if (total <= pageSize) {
return null;
}
return (
<div className="flex items-center justify-between mt-4">
<div className="text-sm text-muted-foreground">
Affichage de {page * pageSize + 1} à{" "}
{Math.min((page + 1) * pageSize, total)} sur {total}
</div>
<div className="flex gap-2">
<Button
variant="outline"
size="sm"
onClick={() => onPageChange(Math.max(0, page - 1))}
disabled={page === 0}
>
Précédent
</Button>
<Button
variant="outline"
size="sm"
onClick={() => onPageChange(page + 1)}
disabled={!hasMore}
>
Suivant
</Button>
</div>
</div>
);
}