Skip to content

Commit

Permalink
fix: table pagination count
Browse files Browse the repository at this point in the history
  • Loading branch information
tonai committed Nov 13, 2023
1 parent ec53f2c commit cc9d101
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/react-front-kit-table/src/Components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function Table<Data extends Record<string, unknown>>(
rowActionNumber = 0,
...mantineTableProps
} = props;
const { enablePagination = true, data, manualPagination } = mantineTableProps;
const { enablePagination = true, manualPagination } = mantineTableProps;
const { classes } = useStyles();
const [confirmAction, setConfirmAction] =
useState<IConfirmAction<Data> | null>(null);
Expand Down Expand Up @@ -319,7 +319,7 @@ export function Table<Data extends Record<string, unknown>>(
},
...mantineTableProps,
});
const { getState, setPageIndex, setPageSize } = table;
const { getPageCount, getState, setPageIndex, setPageSize } = table;
const { pagination } = getState();
const { pageIndex, pageSize } = pagination;

Expand All @@ -344,7 +344,7 @@ export function Table<Data extends Record<string, unknown>>(
onItemsPerPageChange={handleItemsPerPageChange}
onPageChange={handlePageChange}
page={pageIndex + 1}
totalPages={Math.ceil(data.length / pageSize)}
totalPages={getPageCount()}
/>
) : (
paginationProps !== undefined && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ exports[`Table matches snapshot 1`] = `
>
<input
aria-invalid="false"
aria-label="Filter by id"
class="mantine-Input-input mantine-TextInput-input mantine-8fuq20"
placeholder="Filter by id"
title="Filter by id"
Expand Down Expand Up @@ -395,6 +396,7 @@ exports[`Table matches snapshot 1`] = `
>
<input
aria-invalid="false"
aria-label="Filter by Format"
class="mantine-Input-input mantine-TextInput-input mantine-8fuq20"
placeholder="Filter by Format"
title="Filter by Format"
Expand Down Expand Up @@ -506,6 +508,7 @@ exports[`Table matches snapshot 1`] = `
>
<input
aria-invalid="false"
aria-label="Filter by Titre"
class="mantine-Input-input mantine-TextInput-input mantine-8fuq20"
placeholder="Filter by Titre"
title="Filter by Titre"
Expand Down Expand Up @@ -617,6 +620,7 @@ exports[`Table matches snapshot 1`] = `
>
<input
aria-invalid="false"
aria-label="Filter by Créateur"
class="mantine-Input-input mantine-TextInput-input mantine-8fuq20"
placeholder="Filter by Créateur"
title="Filter by Créateur"
Expand Down Expand Up @@ -728,6 +732,7 @@ exports[`Table matches snapshot 1`] = `
>
<input
aria-invalid="false"
aria-label="Filter by Date publication"
class="mantine-Input-input mantine-TextInput-input mantine-8fuq20"
placeholder="Filter by Date publication"
title="Filter by Date publication"
Expand Down

0 comments on commit cc9d101

Please sign in to comment.