mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 03:40:56 +00:00
feat(data-table): Introduce comprehensive DataTable component with full feature set
This commit is contained in:
25
packages/ui-common/src/components/data-table/hooks.ts
Normal file
25
packages/ui-common/src/components/data-table/hooks.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { PaginationState } from "@tanstack/react-table";
|
||||
import { useState } from "react";
|
||||
|
||||
export const usePagination = ({
|
||||
pageSize,
|
||||
pageIndex,
|
||||
}: {
|
||||
pageSize?: number;
|
||||
pageIndex?: number;
|
||||
} = {}) => {
|
||||
const [pagination, setPagination] = useState<PaginationState>({
|
||||
pageIndex: pageIndex ?? 0,
|
||||
pageSize: pageSize ?? 10,
|
||||
});
|
||||
|
||||
const setPage = (pageIndex: number) => {
|
||||
setPagination((prev) => ({ ...prev, pageIndex }));
|
||||
};
|
||||
|
||||
return {
|
||||
pagination,
|
||||
setPagination,
|
||||
setPage,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user