Files
calendar/packages/features/data-table/components/DataTablePagination.tsx
T
853f9bc436 perf: do not import from @calcom/ui barrel file (#20184)
* Icon and IconName

* Button and ButtonGroup

* UserAvatar

* AvatarGroup

* Avatar

* WizardLayout

* Dialogs

* EmptyScreen

* showToast and TextField

* Editor

* Skeleton

* Skeleton

* TopBanner and showToast

* Button again

* more

* perf: Remove app-store reference from @calcom/ui

* more

* Fixing types

* Icon

* Fixed casing

* dropdown

* more

* Select

* more

* Badge

* List

* more

* Divider

* more

* fix

* fix type check

* refactor

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix type check

* fix

* fix

* fix

* fix

* more

* more

* more

* more

* add index file to components/command

* fix

* fix

* fix

* fix imports

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix build errors

* fix build errors

* fix

---------

Co-authored-by: Keith Williams <keithwillcode@gmail.com>
2025-03-19 19:00:55 -03:00

49 lines
1.3 KiB
TypeScript

"use client";
import { type Table } from "@tanstack/react-table";
import { Pagination } from "@calcom/ui/components/pagination";
import { useDataTable } from "../hooks";
interface DataTablePaginationProps<TData> {
table: Table<TData>;
totalRowCount?: number;
paginationMode?: "infinite" | "standard";
}
export function DataTablePagination<TData>({
table,
totalRowCount,
paginationMode = "infinite",
}: DataTablePaginationProps<TData>) {
const { pageIndex, pageSize, setPageIndex, setPageSize } = useDataTable();
if (!totalRowCount) {
return null;
}
if (paginationMode === "infinite") {
const loadedCount = table.getRowModel().rows.length;
return (
<p className="text-subtle text-sm tabular-nums">
Loaded <span className="text-default font-medium">{loadedCount}</span> of{" "}
<span className="text-default font-medium">{totalRowCount}</span>
</p>
);
} else if (paginationMode === "standard") {
return (
<Pagination
currentPage={pageIndex + 1}
pageSize={pageSize}
totalItems={totalRowCount}
onPageChange={(page) => setPageIndex(page - 1)}
onPageSizeChange={(newSize) => setPageSize(newSize)}
onNext={() => setPageIndex(pageIndex + 1)}
onPrevious={() => setPageIndex(pageIndex - 1)}
/>
);
} else {
return null;
}
}