From 97b82a0643c3e4fa57c6bad552e259af2a91b251 Mon Sep 17 00:00:00 2001 From: "Michael J. Kazin" Date: Mon, 18 Mar 2024 12:50:33 -0400 Subject: [PATCH] fix(examples): removed broken custom cursor code (#5757) In table-material-ui-cursor-pagination Data provider was using the most recent date of any fetched data as an "until" filter instead of paging, which caused both forward & backward to go back in the Github API commit list. --- .../src/pages/posts/list.tsx | 14 -------------- .../src/rest-data-provider/index.ts | 4 ++-- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/examples/table-material-ui-cursor-pagination/src/pages/posts/list.tsx b/examples/table-material-ui-cursor-pagination/src/pages/posts/list.tsx index 153cc1823925..df8e35fb42cb 100644 --- a/examples/table-material-ui-cursor-pagination/src/pages/posts/list.tsx +++ b/examples/table-material-ui-cursor-pagination/src/pages/posts/list.tsx @@ -6,14 +6,8 @@ import { DataGrid, GridColDef } from "@mui/x-data-grid"; import { ICommit } from "../../interfaces"; export const PostList: React.FC = () => { - const [next, setNext] = React.useState(undefined); const { dataGridProps, tableQueryResult } = useDataGrid({ initialPageSize: 5, - metaData: { - cursor: { - next, - }, - }, }); const { data } = tableQueryResult; @@ -67,14 +61,6 @@ export const PostList: React.FC = () => { row.sha} {...dataGridProps} - onPaginationModelChange={(model, details) => { - const lastRow = data?.data[data.data.length - 1]; - const next = lastRow?.commit.committer.date; - if (next) { - setNext(next); - } - dataGridProps.onPaginationModelChange?.(model, details); - }} columns={columns} autoHeight /> diff --git a/examples/table-material-ui-cursor-pagination/src/rest-data-provider/index.ts b/examples/table-material-ui-cursor-pagination/src/rest-data-provider/index.ts index 950d3b0c1d28..f2bdc39b8129 100644 --- a/examples/table-material-ui-cursor-pagination/src/rest-data-provider/index.ts +++ b/examples/table-material-ui-cursor-pagination/src/rest-data-provider/index.ts @@ -13,8 +13,8 @@ export const dataProvider = ( getList: async ({ resource, metaData, pagination }) => { let url = `${apiUrl}/${resource}?per_page=${pagination?.pageSize || 10}`; - if (metaData?.cursor?.next) { - url = `${url}&until=${metaData.cursor.next}`; + if (pagination?.current) { + url = `${url}&page=${pagination?.current}`; } const { data } = await httpClient.get(url);