70 lines
1.6 KiB
TypeScript
70 lines
1.6 KiB
TypeScript
import {type GridColDef} from '@mui/x-data-grid'
|
||
import {CustomDataGrid} from '../../components/CustomDataGrid'
|
||
import {DeleteButton, EditButton, List, ShowButton, useDataGrid} from '@refinedev/mui'
|
||
import React from 'react'
|
||
|
||
export const CityList = () => {
|
||
const {dataGridProps} = useDataGrid({})
|
||
|
||
const columns = React.useMemo<GridColDef[]>(
|
||
() => [
|
||
{
|
||
field: 'id',
|
||
headerName: 'ID',
|
||
type: 'number',
|
||
minWidth: 50,
|
||
align: 'left',
|
||
headerAlign: 'left',
|
||
},
|
||
{
|
||
field: 'country_code',
|
||
headerName: 'Код страны',
|
||
type: 'string',
|
||
minWidth: 150,
|
||
align: 'left',
|
||
headerAlign: 'left',
|
||
},
|
||
{
|
||
field: 'country',
|
||
headerName: 'Cтрана',
|
||
type: 'string',
|
||
minWidth: 150,
|
||
align: 'left',
|
||
headerAlign: 'left',
|
||
},
|
||
{
|
||
field: 'name',
|
||
headerName: 'Название',
|
||
type: 'string',
|
||
minWidth: 150,
|
||
flex: 1,
|
||
},
|
||
{
|
||
field: 'actions',
|
||
headerName: 'Действия',
|
||
minWidth: 120,
|
||
display: 'flex',
|
||
align: 'right',
|
||
headerAlign: 'center',
|
||
sortable: false,
|
||
renderCell: function render({row}) {
|
||
return (
|
||
<>
|
||
<EditButton hideText recordItemId={row.id} />
|
||
<ShowButton hideText recordItemId={row.id} />
|
||
<DeleteButton hideText recordItemId={row.id} />
|
||
</>
|
||
)
|
||
},
|
||
},
|
||
],
|
||
[],
|
||
)
|
||
|
||
return (
|
||
<List>
|
||
<CustomDataGrid {...dataGridProps} columns={columns} />
|
||
</List>
|
||
)
|
||
}
|