KickboardHistoryTable.jsx
1.68 KB
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
import React from "react";
import {Table} from "react-bootstrap";
import { Card } from "components/Card/Card.jsx";
import { tdArray } from "variables/Variables.jsx";
const UserDataKey = {
user_id: '유저ID',
rent_datetime: '대여 시각',
return_datetime: '반납 시각',
rental_time: '대여 시간',
rental_distance: '이동 거리',
rental_fee: '대여 금액',
};
class KickboardHistoryTable extends React.Component {
constructor(props) {
super(props);
this.state = {
data: []
};
}
componentDidMount() {
fetch(`http://1.201.143.67:5901/kickboard/rent/${this.props.kbId}`)
.then(r => r.json())
.then(d => {
if(d.data && d.data.length) this.setState({data: d.data});
})
.catch(err => console.log(err));
}
render() {
return (
<Card
title={`${this.props.kbId}번 킥보드 사용자 히스토리`}
ctTableFullWidth
ctTableResponsive
content={
<Table striped hover>
<thead>
<tr>
{Object.values(UserDataKey).map((prop, key) => {
return <th key={key}>{prop}</th>;
})}
</tr>
</thead>
<tbody>
{this.state.data.map((data, idx) => (
<tr key={idx}>
<td>{data.user_id}</td>
<td>{data.rent_datetime}</td>
<td>{data.return_datetime}</td>
<td>{data.rental_time}</td>
<td>{data.rental_distance}</td>
<td>{data.rental_fee}</td>
</tr>
))}
</tbody>
</Table>
}
/>
)
}
};
export default KickboardHistoryTable;