-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathViewBatteryComponent.js
70 lines (60 loc) · 2.58 KB
/
ViewBatteryComponent.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
65
66
67
68
69
70
import React, { useEffect, useState } from 'react';
import { Button, Container, Form } from 'react-bootstrap';
import MotorService from '../../services/MotorService';
import CO2NavBar from '../CO2NavBar';
import SidebarComponent from '../SidebarComponent';
function ViewBatteryComponent(props) {
const [records, setRecords] = useState([]);
useEffect(() => {
async function getBATTERYData() {
//Add Records
try {
const batteryData = await MotorService.getBatteryData();
console.log(batteryData);
setRecords(batteryData.data);
console.log("records:", records)
}
catch (e) {
console.log(e);
}
}
getBATTERYData();
}, []);
return (
<>
<CO2NavBar />
<div className="row">
{/* <div className="col" style={{ width: '5%', border: "10px" }}>
<SidebarComponent />
</div> */}
<div className="col" style={{ margin: '2%', float: 'left' }}>
<Container fluid>
<table>
<tbody>
<tr>
<th>Part Munber</th> 
<th>Serial Number</th> 
<th>CO2</th> 
<th>Cost of Manufacture</th> 
<th>Date Of Manufacture</th> 
<th>Sales Price</th>
</tr>
{records.map((item, i) => (
<tr key={i}>
<td>{item.partNumber}</td>
<td>{item.serialNumber}</td>
<td>{item.co2}</td>
<td>{item.dateManufactured}</td>
<td>{item.costManufactured}</td>
<td>{item.salesPrice}</td>
</tr>
))}
</tbody>
</table>
</Container>
</div>
</div>
</>
);
}
export default ViewBatteryComponent;