init /article
route
This commit is contained in:
65
src/pages/article/list.tsx
Normal file
65
src/pages/article/list.tsx
Normal file
@ -0,0 +1,65 @@
|
||||
import {DataGrid, type GridColDef} from '@mui/x-data-grid'
|
||||
import {DeleteButton, EditButton, List, useDataGrid} from '@refinedev/mui'
|
||||
import React from 'react'
|
||||
|
||||
export const ArticleList = () => {
|
||||
const {dataGridProps} = useDataGrid({
|
||||
resource: 'article/',
|
||||
})
|
||||
|
||||
const columns = React.useMemo<GridColDef[]>(
|
||||
() => [
|
||||
{
|
||||
field: 'id',
|
||||
headerName: 'ID',
|
||||
type: 'number',
|
||||
minWidth: 70,
|
||||
display: 'flex',
|
||||
align: 'left',
|
||||
headerAlign: 'left',
|
||||
},
|
||||
{
|
||||
field: 'heading',
|
||||
headerName: 'Heading',
|
||||
type: 'string',
|
||||
minWidth: 300,
|
||||
display: 'flex',
|
||||
align: 'left',
|
||||
headerAlign: 'left',
|
||||
},
|
||||
{
|
||||
field: 'body',
|
||||
headerName: 'Body',
|
||||
type: 'string',
|
||||
display: 'flex',
|
||||
align: 'left',
|
||||
headerAlign: 'left',
|
||||
flex: 1,
|
||||
},
|
||||
{
|
||||
field: 'actions',
|
||||
headerName: 'Actions',
|
||||
align: 'right',
|
||||
headerAlign: 'center',
|
||||
minWidth: 100,
|
||||
sortable: false,
|
||||
display: 'flex',
|
||||
renderCell: function render({row}) {
|
||||
return (
|
||||
<>
|
||||
<EditButton hideText recordItemId={row.id} />
|
||||
<DeleteButton hideText recordItemId={row.id} />
|
||||
</>
|
||||
)
|
||||
},
|
||||
},
|
||||
],
|
||||
[],
|
||||
)
|
||||
|
||||
return (
|
||||
<List>
|
||||
<DataGrid {...dataGridProps} columns={columns} getRowId={(row: any) => row.id} />
|
||||
</List>
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user