-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.tsx
98 lines (89 loc) · 2.99 KB
/
index.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import type { NextPage } from "next";
import styles from "../styles/Home.module.css";
import Link from "next/link";
import {
MediaRenderer,
useActiveListings,
useMarketplace,
} from "@thirdweb-dev/react";
import { useRouter } from "next/router";
const Home: NextPage = () => {
const router = useRouter();
// Connect your marketplace smart contract here (replace this address)
const marketplace = useMarketplace(
"0x277C0FB19FeD09c785448B8d3a80a78e7A9B8952" // Your marketplace contract address here
);
const { data: listings, isLoading: loadingListings } =
useActiveListings(marketplace);
return (
<>
{/* Content */}
<div className={styles.container}>
{/* Top Section */}
<h1 className={styles.h1}>NFT Marketplace w/ thirdweb + Next.JS</h1>
<p className={styles.explain}>
Build an NFT marketplace using{" "}
<b>
{" "}
<a
href="https://thirdweb.com/"
target="_blank"
rel="noopener noreferrer"
className={styles.purple}
>
thirdweb
</a>
</b>{" "}
to list your ERC721 and ERC1155 tokens for auction or for direct sale.
</p>
<hr className={styles.divider} />
<div style={{ marginTop: 32, marginBottom: 32 }}>
<Link href="/create">
<a className={styles.mainButton} style={{ textDecoration: "none" }}>
Create A Listing
</a>
</Link>
</div>
<div className="main">
{
// If the listings are loading, show a loading message
loadingListings ? (
<div>Loading listings...</div>
) : (
// Otherwise, show the listings
<div className={styles.listingGrid}>
{listings?.map((listing) => (
<div
key={listing.id}
className={styles.listingShortView}
onClick={() => router.push(`/listing/${listing.id}`)}
>
<MediaRenderer
src={listing.asset.image}
style={{
borderRadius: 16,
// Fit the image to the container
width: "100%",
height: "100%",
}}
/>
<h2 className={styles.nameContainer}>
<Link href={`/listing/${listing.id}`}>
<a className={styles.name}>{listing.asset.name}</a>
</Link>
</h2>
<p>
<b>{listing.buyoutCurrencyValuePerToken.displayValue}</b>{" "}
{listing.buyoutCurrencyValuePerToken.symbol}
</p>
</div>
))}
</div>
)
}
</div>
</div>
</>
);
};
export default Home;