-
Notifications
You must be signed in to change notification settings - Fork 0
/
Table.js
72 lines (50 loc) · 1.84 KB
/
Table.js
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
import {useEffect,useState } from 'react'
import './Table.css';
import { DataGrid } from '@mui/x-data-grid';
// components for showing the table in the dashboard
//takes in props which it uses to load the table with data
// this is a material ui component mainly, which was edited to take a prop rather than const variables to load the table
// https://mui.com/material-ui/react-table/
// const Table = (assets,handleSetSelection) => {
const Table = (props) => {
console.log("Inside table");
// console.log(props);
console.log(props.assets);
// console.log(props.assets.assets);
// const tempArray = props.assets.assets
const tempArray = props.assets
// column headings
const columns = [
{ field: 'id', headerName: 'ID', width: 130 },
{ field: 'assetName', headerName: 'Asset name', width: 250 },
{field: 'quantity', headerName: 'Quantity', width: 250},
{ field: 'completed', headerName: 'Completed', width: 180 },
{ field: 'cancelled', headerName: 'Cancelled', width: 180 },
];
// use tempArray as the row data
const rows = tempArray
// const rows = []
return(
<>
{/* {assets>0 &&
<>
<Button classVar='dark' text={'asset'} onClick={(e)=> {asset.map((item)=>{console.log(item)})}}/>
<Button classVar='dark' text={'count'} onClick={(e)=> {asset.map((item)=>{console.log(assetCount)})}}/>
</>
} */}
<div className='table' style={{ height: 400, width: '100%' }}>
<DataGrid
rows={rows}
columns={columns}
pageSize={5}
rowsPerPageOptions={[5]}
checkboxSelection
onSelectionModelChange={itm => props.handleSetSelection(itm)}
// onSelectionModelChange={props.handleSetSelection([2,4])}
// handleSetSelection('itm')
/>
</div>
</>
)
}
export default Table