UserHistoryCard.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
import React, { Component } from "react";
import { Grid, Row, Col, Table } from "react-bootstrap";
import styled from "styled-components";
import Card from "components/Card/Card.jsx";
import { tdArray } from "variables/Variables.jsx";
import moment from "moment";
const thArray = ['킥보드 시리얼 번호', '대여 시각', '반납 시각', '총 대여 시간', '이동 거리', '대여 금액'];
function timestampToString(stamp) {
if (!stamp) return '';
const date = stamp.split('T')[0];
const time = stamp.split('T')[1].split('.')[0];
return `${date} ${time}`;
}
const UserHistoryCard = (props) => {
const {userId, rentData} = props;
const getStats = `마지막 업데이트 ${moment().format("YYYY/MM/DD hh:mm")}`;
return (
<Card
title={`${userId}번 사용자 킥보드 사용 히스토리`}
ctTableResponsive
stats={getStats}
statsIcon="fa fa-history"
content={
<Table striped hover>
<thead>
<tr>
{thArray.map((prop, key) => {
return <th key={key}>{prop}</th>;
})}
</tr>
</thead>
<tbody>
{rentData.map((data, idx) => (
<tr key={idx}>
<td>{data.serial_number}</td>
<td>{timestampToString(data.rent_datetime)}</td>
<td>{timestampToString(data.return_datetime)}</td>
<td>{data.rental_time}분</td>
<td>{data.rental_distance}km</td>
<td>{data.rental_fee}원</td>
</tr>
))}
</tbody>
</Table>
}
/>
);
};
export default UserHistoryCard;