|
1 | 1 | import { useCallback, useEffect, useMemo, useState } from "react"; |
2 | 2 | import { FormattedDate, FormattedTime, injectIntl } from "react-intl"; |
3 | 3 | import { Link } from "react-router-dom"; |
4 | | -import { useResizeColumns, useSortBy, useTable } from "react-table"; |
| 4 | +import { usePagination, useResizeColumns, useSortBy, useTable } from "react-table"; |
5 | 5 | import WithCurrentUser from "../../components/HOCs/WithCurrentUser/WithCurrentUser"; |
6 | 6 | import PaginationControl from "../../components/PaginationControl/PaginationControl"; |
7 | 7 | import { TableWrapper, renderTableHeader } from "../../components/TableShared/EnhancedTable"; |
@@ -176,6 +176,7 @@ const Sent = (props) => { |
176 | 176 | }, |
177 | 177 | useSortBy, |
178 | 178 | useResizeColumns, |
| 179 | + usePagination, |
179 | 180 | ); |
180 | 181 |
|
181 | 182 | useEffect(() => { |
@@ -264,20 +265,15 @@ const Sent = (props) => { |
264 | 265 | </TableWrapper> |
265 | 266 |
|
266 | 267 | <PaginationControl |
267 | | - currentPage={props.criteria?.page || 0} |
268 | | - pageCount={Math.ceil((props.totalTaskCount || 0) / (props.criteria?.pageSize || 20))} |
269 | | - pageSize={props.criteria?.pageSize || 20} |
270 | | - gotoPage={(page) => props.updateCriteria({ page })} |
271 | | - setPageSize={(pageSize) => props.updateCriteria({ pageSize, page: 0 })} |
272 | | - previousPage={() => |
273 | | - props.updateCriteria({ page: Math.max(0, (props.criteria?.page || 0) - 1) }) |
274 | | - } |
275 | | - nextPage={() => { |
276 | | - const maxPage = |
277 | | - Math.ceil((props.totalTaskCount || 0) / (props.criteria?.pageSize || 20)) - 1; |
278 | | - props.updateCriteria({ page: Math.min(maxPage, (props.criteria?.page || 0) + 1) }); |
279 | | - }} |
280 | | - /> |
| 268 | + currentPage={pagination.page} |
| 269 | + pageCount={totalPages} |
| 270 | + pageSize={pagination.pageSize} |
| 271 | + gotoPage={(page) => setPagination({ ...pagination, page })} |
| 272 | + setPageSize={(pageSize) => setPagination({ ...pagination, pageSize })} |
| 273 | + previousPage={() => setPagination({ ...pagination, page: pagination.page - 1 })} |
| 274 | + nextPage={() => setPagination({ ...pagination, page: pagination.page + 1 })} |
| 275 | + intl={props.intl} |
| 276 | + /> |
281 | 277 |
|
282 | 278 | {selectedComment && ( |
283 | 279 | <Notification |
|
0 commit comments