-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
88 lines (73 loc) · 1.99 KB
/
App.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
import { Button, Card, Input, Layout, List, message } from "antd";
import { useState } from "react";
import { getContractNFTs } from "./utils";
import "./App.css";
import NftCard from "./components/NftCard";
import ContractTrades from "./components/ContractTrades";
const { Header, Content } = Layout;
function App() {
const [nfts, setNfts] = useState([]);
const [loading, setLoading] = useState(false);
const [searchText, setSearchText] = useState("");
const handleSearch = async () => {
if (searchText === "") {
return;
}
setLoading(true);
try {
const data = await getContractNFTs(searchText);
setNfts(data.result);
} catch (error) {
message.error(error.message);
} finally {
setLoading(false);
}
};
return (
<Layout style={{ height: "100vh" }}>
<Header>
<div style={{ fontSize: 16, fontWeight: 600, color: "white" }}>
NFT Browser
</div>
</Header>
<Content
style={{ height: "calc(100% - 64px)", padding: 20, overflowY: "auto" }}
>
<Input.Group compact>
<Input
style={{ width: 1000
}}
placeholder="Enter a NFT contract address to search"
value={searchText}
onChange={(e) => setSearchText(e.target.value)}
/>
<Button type="primary" onClick={handleSearch}>
Search
</Button>
<ContractTrades tokenAddress={searchText} />
</Input.Group>
<List
loading={loading}
style={{
marginTop: 20,
height: "calc(100% - 52px)",
overflow: "auto",
}}
grid={{
gutter: 16,
xs: 1,
sm: 3,
md: 3,
lg: 3,
xl: 4,
xxl: 4,
xxxl: 7,
}}
dataSource={nfts}
renderItem={(nft) => <NftCard nft={nft} />}
/>
</Content>
</Layout>
);
}
export default App;