Files
calendar/apps/web/modules/data-table/components/DataTablePagination.tsx
T
Eunjae LeeGitHubDevin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1368ffe55d refactor: move data-table hooks/contexts/provider from features to web modules (#27833)
* refactor: move data-table hooks/contexts/provider from features to web modules

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: update broken useColumnResizing import path in DataTable.tsx

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: update remaining broken import paths for moved hooks

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* docs: update GUIDE.md import paths and file references for moved modules

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-02-13 00:00:40 +09:00

47 lines
1.2 KiB
TypeScript

"use client";
import { type Table } from "@tanstack/react-table";
import { Pagination } from "@calcom/ui/components/pagination";
import { useDataTable } from "~/data-table/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}
onPageSizeChange={(newSize) => setPageSize(newSize)}
onPageChange={(page) => setPageIndex(page - 1)}
/>
);
} else {
return null;
}
}