-
Notifications
You must be signed in to change notification settings - Fork 0
/
NftTransfers.js
94 lines (76 loc) · 1.81 KB
/
NftTransfers.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { Button, Modal, Skeleton, Table, Tooltip } from "antd";
import { useEffect, useState } from "react";
import { InfoCircleOutlined } from "@ant-design/icons";
import { getNFTTransfers } from "../utils";
const columns = [
{
title: "Transfer DateTime",
dataIndex: "block_timestamp",
key: "block_timestamp",
render: (value) => {
return new Date(value).toLocaleString();
},
},
{
title: "Amount",
dataIndex: "amount",
key: "amount",
},
{
title: "From Address",
dataIndex: "from_address",
key: "from_address",
},
{
title: "To Address",
dataIndex: "to_address",
key: "to_address",
},
];
const ModalContent = ({ nft }) => {
const [loading, setLoading] = useState(true);
const [data, setData] = useState([]);
const { token_address, token_id } = nft;
useEffect(() => {
getNFTTransfers(token_address, token_id)
.then((resp) => {
setData(resp.result);
})
.finally(() => {
setLoading(false);
});
}, []);
if (loading) {
return <Skeleton active />;
}
return (
<Table columns={columns} dataSource={data} pagination={{ pageSize: 5 }} />
);
};
const NftTransfers = ({ nft }) => {
const [modalOpen, setModalOpen] = useState(false);
return (
<>
<Tooltip title="Transfer(s) on this NFT">
<Button
style={{ border: "none" }}
size="large"
shape="circle"
icon={<InfoCircleOutlined />}
onClick={() => setModalOpen(true)}
/>
</Tooltip>
<Modal
width={1000}
title="Transfer(s) List"
destroyOnClose
open={modalOpen}
footer={null}
onCancel={() => setModalOpen(false)}
>
<ModalContent nft={nft} />
</Modal>
</>
);
};
export default NftTransfers;