KickboardHistoryTable.jsx
1.63 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
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: '대여 금액',
};
function timestampToString(stamp) {
if (!stamp) return '';
const date = stamp.split('T')[0];
const time = stamp.split('T')[1].split('.')[0];
return `${date} ${time}`;
}
const KickboardHistoryTable = (props) => {
const {kbId, historyData} = props;
return (
<Card
title={`${kbId}번 킥보드 사용자 히스토리`}
ctTableFullWidth
ctTableResponsive
content={
<Table striped hover>
<thead>
<tr>
{Object.values(UserDataKey).map((prop, key) => {
return <th key={key}>{prop}</th>;
})}
</tr>
</thead>
<tbody>
{historyData.map((data, idx) => {
const {user_id, rent_datetime, return_datetime, rental_time, rental_distance, rental_fee} = data;
return (
<tr key={idx}>
<td>{user_id}</td>
<td>{timestampToString(rent_datetime)}</td>
<td>{timestampToString(return_datetime)}</td>
<td>{rental_time}분</td>
<td>{rental_distance}km</td>
<td>{rental_fee}원</td>
</tr>
);
})}
</tbody>
</Table>
}
/>
)
};
export default KickboardHistoryTable;