Skip to content

Commit

Permalink
Use createDisplayPage to paginate ordered data list
Browse files Browse the repository at this point in the history
  • Loading branch information
pmakode-akamai committed Oct 3, 2024
1 parent dfbec6c commit f7bd03d
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Currency } from 'src/components/Currency';
import { DateTimeDisplay } from 'src/components/DateTimeDisplay';
import { InlineMenuAction } from 'src/components/InlineMenuAction/InlineMenuAction';
import { Link } from 'src/components/Link';
import { createDisplayPage } from 'src/components/Paginate';
import { PaginationFooter } from 'src/components/PaginationFooter/PaginationFooter';
import { Table } from 'src/components/Table';
import { TableBody } from 'src/components/TableBody';
Expand Down Expand Up @@ -324,10 +325,12 @@ export const BillingActivityPanel = React.memo((props: Props) => {
return new Date(b.date).getTime() - new Date(a.date).getTime();
});

const start = (pagination.page - 1) * pagination.pageSize;
const end = start + pagination.pageSize;
const displayPage = createDisplayPage<ActivityFeedItem>(
pagination.page,
pagination.pageSize
);

return orderedData.slice(start, end);
return displayPage(orderedData);
}, [data, orderBy, order, pagination.page, pagination.pageSize]);

const renderTableContent = () => {
Expand Down

0 comments on commit f7bd03d

Please sign in to comment.