forked from VinokurovVE/tests
Servers API
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { useEffect, useState } from "react"
|
||||
import { Box, Button, Typography } from "@mui/material"
|
||||
import axiosInstance from "../http/axiosInstance"
|
||||
import DataTable from "../components/DataTable"
|
||||
import { DataGrid } from "@mui/x-data-grid"
|
||||
|
||||
export default function Reports() {
|
||||
const [state, setState] = useState<any>(null)
|
||||
@ -43,27 +43,42 @@ export default function Reports() {
|
||||
</Box>
|
||||
|
||||
{state &&
|
||||
<DataTable
|
||||
<DataGrid
|
||||
autoHeight
|
||||
style={{ width: "100%" }}
|
||||
rows={[...new Set(Object.keys(state).flatMap(key => Object.keys(state[key])))].map(id => {
|
||||
const row: any = { id: Number(id) };
|
||||
Object.keys(state).forEach(key => {
|
||||
row[key] = state[key][id];
|
||||
});
|
||||
return row;
|
||||
})}
|
||||
columns={[
|
||||
{ field: 'id', headerName: '№', width: 70 },
|
||||
...Object.keys(state).map(key => ({
|
||||
field: key,
|
||||
headerName: key.charAt(0).toUpperCase() + key.slice(1),
|
||||
width: 150
|
||||
}))
|
||||
]}
|
||||
initialState={{
|
||||
pagination: {
|
||||
paginationModel: { page: 0, pageSize: 10 },
|
||||
},
|
||||
}}
|
||||
pageSizeOptions={[10, 20, 50, 100]}
|
||||
checkboxSelection={false}
|
||||
columns={
|
||||
[
|
||||
{ field: 'id', headerName: '№', width: 70 },
|
||||
...Object.keys(state).map(key => ({
|
||||
field: key,
|
||||
headerName: key.charAt(0).toUpperCase() + key.slice(1),
|
||||
width: 150
|
||||
}))
|
||||
]
|
||||
}
|
||||
rows={
|
||||
[...new Set(Object.keys(state).flatMap(key => Object.keys(state[key])))].map(id => {
|
||||
const row: any = { id: Number(id) };
|
||||
Object.keys(state).forEach(key => {
|
||||
row[key] = state[key][id];
|
||||
});
|
||||
return row;
|
||||
})
|
||||
} />
|
||||
disableRowSelectionOnClick
|
||||
|
||||
processRowUpdate={(updatedRow, originalRow) => {
|
||||
console.log(updatedRow)
|
||||
return updatedRow
|
||||
}}
|
||||
|
||||
onProcessRowUpdateError={(error) => {
|
||||
console.log(error)
|
||||
}}
|
||||
/>
|
||||
}
|
||||
</Box>
|
||||
</>
|
||||
|
Reference in New Issue
Block a user