mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-29 16:14:43 +00:00
Pagination component
This commit is contained in:
35
components/Pagination.tsx
Normal file
35
components/Pagination.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
export default function Pagination({
|
||||
currentPage,
|
||||
totalItems,
|
||||
itemsPerPage,
|
||||
onPageChange
|
||||
}: {
|
||||
currentPage: number;
|
||||
totalItems: number;
|
||||
itemsPerPage: number;
|
||||
onPageChange: (page: number) => void;
|
||||
}) {
|
||||
const totalPages = Math.ceil(totalItems / itemsPerPage);
|
||||
|
||||
return (
|
||||
<div className="flex justify-center pt-4">
|
||||
<div className="join">
|
||||
<button
|
||||
className="join-item btn"
|
||||
onClick={() => onPageChange(currentPage - 1)}
|
||||
disabled={currentPage === 1}
|
||||
>
|
||||
«
|
||||
</button>
|
||||
<button className="join-item btn">Page {currentPage}</button>
|
||||
<button
|
||||
className="join-item btn"
|
||||
onClick={() => onPageChange(currentPage + 1)}
|
||||
disabled={currentPage === totalPages}
|
||||
>
|
||||
»
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user