-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsell.tsx
76 lines (71 loc) · 2.51 KB
/
sell.tsx
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
import {
ThirdwebNftMedia,
useAddress,
useContract,
useOwnedNFTs,
} from "@thirdweb-dev/react";
import React, { useState } from "react";
import Container from "../components/Container/Container";
import NFTGrid from "../components/NFT/NFTGrid";
import { NFT_COLLECTION_ADDRESS } from "../const/contractAddresses";
import tokenPageStyles from "../styles/Token.module.css";
import { NFT as NFTType } from "@thirdweb-dev/sdk";
import SaleInfo from "../components/SaleInfo/SaleInfo";
export default function Sell() {
// Load all of the NFTs from the NFT Collection
const { contract } = useContract(NFT_COLLECTION_ADDRESS);
const address = useAddress();
const { data, isLoading } = useOwnedNFTs(contract, address);
const [selectedNft, setSelectedNft] = useState<NFTType>();
return (
<Container maxWidth="lg">
<h1>Sell NFTs</h1>
{!selectedNft ? (
<>
<p>Select which NFT you’d like to sell below.</p>
<NFTGrid
data={data}
isLoading={isLoading}
overrideOnclickBehavior={(nft) => {
setSelectedNft(nft);
}}
emptyText={
"Looks like you don't own any NFTs in this collection. Head to the buy page to buy some!"
}
/>
</>
) : (
<div className={tokenPageStyles.container} style={{ marginTop: 0 }}>
<div className={tokenPageStyles.metadataContainer}>
<div className={tokenPageStyles.imageContainer}>
<ThirdwebNftMedia
metadata={selectedNft.metadata}
className={tokenPageStyles.image}
/>
<button
onClick={() => {
setSelectedNft(undefined);
}}
className={tokenPageStyles.crossButton}
>
X
</button>
</div>
</div>
<div className={tokenPageStyles.listingContainer}>
<p>You’re about to list the following item for sale.</p>
<h1 className={tokenPageStyles.title}>
{selectedNft.metadata.name}
</h1>
<p className={tokenPageStyles.collectionName}>
Token ID #{selectedNft.metadata.id}
</p>
<div className={tokenPageStyles.pricingContainer}>
<SaleInfo nft={selectedNft} />
</div>
</div>
</div>
)}
</Container>
);
}