-
-
Notifications
You must be signed in to change notification settings - Fork 2k
/
list.tsx
83 lines (77 loc) · 1.81 KB
/
list.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { List, useDataGrid } from "@refinedev/mui";
import React from "react";
import { DataGrid, GridColDef } from "@mui/x-data-grid";
import { ICommit } from "../../interfaces";
export const PostList: React.FC = () => {
const [next, setNext] = React.useState<string | undefined>(undefined);
const { dataGridProps, tableQueryResult } = useDataGrid<ICommit>({
initialPageSize: 5,
metaData: {
cursor: {
next,
},
},
});
const { data } = tableQueryResult;
const columns: GridColDef<ICommit>[] = [
{
field: "sha",
headerName: "SHA",
type: "string",
width: 100,
filterable: false,
sortable: false,
},
{
field: "message",
headerName: "Message",
minWidth: 400,
flex: 1,
filterable: false,
sortable: false,
renderCell: ({ row }) => {
return row.commit.message;
},
},
{
field: "author",
headerName: "Author",
minWidth: 140,
flex: 1,
filterable: false,
sortable: false,
renderCell: ({ row }) => {
return row.commit.author.name;
},
},
{
field: "date",
headerName: "Date",
minWidth: 140,
flex: 1,
filterable: false,
sortable: false,
renderCell: ({ row }) => {
return row.commit.author.date;
},
},
];
return (
<List>
<DataGrid
getRowId={(row) => 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
/>
</List>
);
};