mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-11-09 04:38:49 +00:00
68 lines
2.3 KiB
TypeScript
68 lines
2.3 KiB
TypeScript
import { Button } from "@nextui-org/react";
|
|
import {
|
|
ChevronLeftIcon,
|
|
ChevronRightIcon,
|
|
DoubleArrowLeftIcon,
|
|
DoubleArrowRightIcon,
|
|
} from "@radix-ui/react-icons";
|
|
import { type Table } from "@tanstack/react-table";
|
|
|
|
interface DataTablePaginationProps<TData> {
|
|
table: Table<TData>;
|
|
pageSizeOptions?: number[];
|
|
}
|
|
|
|
export function DataTablePagination<TData>({
|
|
table,
|
|
}: DataTablePaginationProps<TData>) {
|
|
// console.log(table);
|
|
return (
|
|
<div className="flex w-full flex-col-reverse items-center justify-between gap-4 overflow-auto p-1 sm:flex-row sm:gap-8">
|
|
<div className="flex flex-col-reverse items-center gap-4 sm:flex-row sm:gap-6 lg:gap-8">
|
|
<div className="flex items-center justify-center text-sm font-medium">
|
|
Page {table.getState().pagination.pageIndex + 1} of{" "}
|
|
{table.getPageCount()}
|
|
</div>
|
|
<div className="flex items-center space-x-2">
|
|
<Button
|
|
aria-label="Go to first page"
|
|
variant="light"
|
|
className="hidden size-8 p-0 lg:flex"
|
|
onClick={() => table.setPageIndex(0)}
|
|
disabled={!table.getCanPreviousPage()}
|
|
>
|
|
<DoubleArrowLeftIcon className="size-4" aria-hidden="true" />
|
|
</Button>
|
|
<Button
|
|
aria-label="Go to previous page"
|
|
variant="light"
|
|
className="size-8"
|
|
onClick={() => table.previousPage()}
|
|
disabled={!table.getCanPreviousPage()}
|
|
>
|
|
<ChevronLeftIcon className="size-4" aria-hidden="true" />
|
|
</Button>
|
|
<Button
|
|
aria-label="Go to next page"
|
|
variant="light"
|
|
className="size-8"
|
|
onClick={() => table.nextPage()}
|
|
disabled={!table.getCanNextPage()}
|
|
>
|
|
<ChevronRightIcon className="size-4" aria-hidden="true" />
|
|
</Button>
|
|
<Button
|
|
aria-label="Go to last page"
|
|
variant="light"
|
|
className="hidden size-8 lg:flex"
|
|
onClick={() => table.setPageIndex(table.getPageCount() - 1)}
|
|
disabled={!table.getCanNextPage()}
|
|
>
|
|
<DoubleArrowRightIcon className="size-4" aria-hidden="true" />
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|