Skip to content

Commit 7384e45

Browse files
AlexVlasoDruxight
andauthored
th-159: * table fixed page size (#160)
Co-authored-by: Stanislav Malyshevskyi <[email protected]>
1 parent 56b820d commit 7384e45

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

frontend/src/libs/components/table/table.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
flexRender,
33
getCoreRowModel,
44
getPaginationRowModel,
5+
useCallback,
56
useReactTable,
67
} from '~/libs/hooks/hooks.js';
78
import { type ColumnDef } from '~/libs/types/types.js';
@@ -41,6 +42,15 @@ const Table = <T,>({
4142
},
4243
});
4344

45+
const handleChangePageSize = useCallback(
46+
(value: number) => {
47+
changePageIndex(0);
48+
changePageSize(value);
49+
table.setPageSize(value);
50+
},
51+
[changePageSize, table, changePageIndex],
52+
);
53+
4454
const createThead = (): JSX.Element => (
4555
<thead className={styles.thead}>
4656
{table.getHeaderGroups().map((headerGroup) => (
@@ -83,7 +93,7 @@ const Table = <T,>({
8393
<Pagination
8494
pageCount={pagesRange}
8595
onClick={changePageIndex}
86-
onChangePageSize={changePageSize}
96+
onChangePageSize={handleChangePageSize}
8797
pageIndex={pageIndex}
8898
pageSize={pageSize}
8999
/>

frontend/src/libs/hooks/use-app-table/use-app-table.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ type Properties<T> = {
1010
pageSize: number;
1111
pageIndex: number;
1212
}) => AppThunk<EntityPagination<T>>;
13-
initialPageSize: number;
14-
initialPageIndex: number;
13+
initialPageSize?: number;
14+
initialPageIndex?: number;
1515
};
1616

1717
type ReturnValue = {

0 commit comments

Comments
 (0)