Skip to content

Commit

Permalink
updated frontend, hardhat and graph
Browse files Browse the repository at this point in the history
  • Loading branch information
Keinberger committed Sep 14, 2022
1 parent fb25e7e commit 6e67a1c
Show file tree
Hide file tree
Showing 27 changed files with 112 additions and 1,113 deletions.
15 changes: 5 additions & 10 deletions frontend/components/ContentManager.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMoralis } from "react-moralis"
import { useEffect, useState } from "react"
import { useQuery, gql } from "@apollo/client"
import { useCookies, withCookies } from "react-cookie"
import { useCookies } from "react-cookie"

import NavBar from "./NavBar"
import NftsListed from "./sites/NftsListed"
Expand All @@ -12,9 +12,9 @@ import WalletNotConnected from "./sites/WalletNotConnected"

const deadAddress = "0x000000000000000000000000000000000000dEaD"

export default withCookies(function ContentManager() {
const [content, setContent] = useState(0)
export default function ContentManager() {
const [cookies, setCookie] = useCookies(["currentSite", "latestMessage"])
const [content, setContent] = useState(0)
const items = ["Explore NFTs", "MyNFTs", "My Sales", "My Purchases"]

const { isWeb3Enabled, account } = useMoralis()
Expand Down Expand Up @@ -107,12 +107,7 @@ export default withCookies(function ContentManager() {

return (
<section>
<NavBar
items={items}
cookieValues={cookies}
contentFunc={setContent}
activeItem={content}
/>
<NavBar items={items} contentFunc={setContent} activeItem={content} />

{isWeb3Enabled ? (
content == 0 ? (
Expand Down Expand Up @@ -147,4 +142,4 @@ export default withCookies(function ContentManager() {
)}
</section>
)
})
}
27 changes: 0 additions & 27 deletions frontend/components/DarkModeSwitcher.js

This file was deleted.

8 changes: 4 additions & 4 deletions frontend/components/NavBar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useEffect, useState } from "react"
import DarkModeSwitcher from "./DarkModeSwitcher"
import { ShareIcon } from "@heroicons/react/outline"
import { ConnectButton } from "@web3uikit/web3"
import { useNotification } from "@web3uikit/core"
Expand Down Expand Up @@ -42,6 +41,7 @@ export default function NavBar(props) {
<div className="hidden lg:flex lg:scale-100 space-x-4 mx-auto text-base bg-gray-100 dark:bg-gray-700 py-1 px-1 rounded-xl border-gray-800 drop-shadow-xl">
{props.items.map((item, index) => (
<button
key={index}
className={`${
index == props.activeItem ? "activeNav" : "0"
} px-3 py-1 text-slate-500 hover:text-slate-800 dark:text-gray-400 dark:hover:text-gray-200 rounded-xl transition ease-in-out duration-300`}
Expand All @@ -55,10 +55,9 @@ export default function NavBar(props) {
))}

<a
href={
"https://www.tally.xyz/governance/eip155:5:0x9AC7819185CbD8b0156F4B339090A2eA0F525229"
}
href={process.env.NEXT_PUBLIC_TALLY_URL}
target="_blank"
rel="noreferrer"
>
<button
className={`items-center flex px-4 py-1 text-slate-500 hover:text-slate-800 dark:text-gray-400 dark:hover:text-gray-200 transition ease-in-out duration-300`}
Expand Down Expand Up @@ -94,6 +93,7 @@ export default function NavBar(props) {
<div className={`${switcherClicked ? "active" : ""} dropdown`}>
{props.items.map((item, index) => (
<button
key={index}
className={`${
index == props.activeItem ? "activeNav" : "0"
} px-3 py-1 text-slate-500 hover:text-slate-800 dark:text-gray-400 dark:hover:text-gray-200 rounded-xl transition ease-in-out duration-300`}
Expand Down
6 changes: 3 additions & 3 deletions frontend/components/sites/MyNftPurchases.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export default function MyNftPurchases(props) {
</div>
{props.nfts !== undefined && props.nfts.length > 0 ? (
<div className="mt-10 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 relative gap-x-8 gap-y-8 sm:gap-y-16 items-center mx-auto">
{props.nfts.map((nft) => (
<div className="mx-auto md:mx-0">
{props.nfts.map((nft, index) => (
<div className="mx-auto md:mx-0" key={index}>
<NFT
price={nft.price}
nftAddress={nft.nftAddress}
Expand All @@ -32,7 +32,7 @@ export default function MyNftPurchases(props) {
) : (
<div className="mx-auto text-center mt-28 space-y-3">
<h1 className="text-3xl text-slate-600 drop-shadow-xl">
You haven't purchased any{" "}
You haven&apos;t purchased any{" "}
<span className="text-slate-800 py-1 px-2 border border-slate-800 rounded-xl">
NFTs
</span>{" "}
Expand Down
6 changes: 3 additions & 3 deletions frontend/components/sites/MyNftSales.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ export default function MyNftSales(props) {

{props.nfts !== undefined && props.nfts.length > 0 ? (
<div className="mt-10 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 relative gap-x-8 gap-y-8 sm:gap-y-16 items-center mx-auto">
{props.nfts.map((nft) => (
<div className="mx-auto md:mx-0">
{props.nfts.map((nft, index) => (
<div className="mx-auto md:mx-0" key={index}>
<NFT
price={nft.price}
nftAddress={nft.nftAddress}
Expand All @@ -120,7 +120,7 @@ export default function MyNftSales(props) {
) : (
<div className="mx-auto text-center mt-20 space-y-3">
<h1 className="text-3xl text-slate-600 drop-shadow-xl">
You haven't sold any{" "}
You haven&apos;t sold any{" "}
<span className="text-slate-800 py-1 px-2 border border-slate-800 rounded-xl">
NFTs
</span>{" "}
Expand Down
24 changes: 3 additions & 21 deletions frontend/components/sites/MyNfts.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export default function MyNfts(props) {
</div>
{accountNfts !== undefined && accountNfts.length > 0 ? (
<div className="mt-10 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 relative gap-x-8 sm:gap-y-16 items-center mx-auto">
{accountNfts.map((nft) => (
<div className="mx-auto md:mx-0">
{accountNfts.map((nft, index) => (
<div className="mx-auto md:mx-0" key={index}>
<NFT
price={nft.price}
nftAddress={nft.nftAddress}
Expand All @@ -90,7 +90,7 @@ export default function MyNfts(props) {
) : (
<div className="mx-auto text-center mt-28 space-y-3">
<h1 className="text-3xl text-slate-600 drop-shadow-xl">
You don't have any{" "}
You don&apos;t have any{" "}
<span className="text-slate-800 py-1 px-2 border border-slate-800 rounded-xl">
NFTs
</span>{" "}
Expand All @@ -101,24 +101,6 @@ export default function MyNfts(props) {
</p>
</div>
)}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 relative gap-x-8 sm:gap-y-16 items-center mx-auto">
{accountNfts !== undefined && accountNfts.length > 0
? accountNfts.map((nft) => (
<div className="mx-auto md:mx-0">
<NFT
price={nft.price}
nftAddress={nft.nftAddress}
tokenId={nft.tokenId}
ownerAddress={account}
paymentTokens={nft.paymentTokens}
activePaymentTokens={props.activePaymentTokens}
type={nft.type}
requireReload={props.requireReload}
/>
</div>
))
: ""}
</div>
</div>
</div>
</section>
Expand Down
4 changes: 2 additions & 2 deletions frontend/components/sites/NftsListed.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export default function NftsListed(props) {
</div>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 relative gap-x-8 gap-y-8 sm:gap-y-16 items-center mx-auto">
{props.nfts !== undefined && props.nfts.length > 0
? props.nfts.map((nft) => (
<div className="mx-auto md:mx-0">
? props.nfts.map((nft, index) => (
<div className="mx-auto md:mx-0" key={index}>
<NFT
price={nft.price}
nftAddress={nft.nftAddress}
Expand Down
14 changes: 10 additions & 4 deletions frontend/components/web3/BigNFT.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export default function BigNFT({
: "https://etherscan.io/address/" + nftAddress
}
target="_blank"
rel="noreferrer"
>
{nftAddress}
</a>
Expand All @@ -74,6 +75,7 @@ export default function BigNFT({
: "https://etherscan.io/address/" + nftAddress
}
target="_blank"
rel="noreferrer"
>
{truncateStr(nftAddress, 15)}
</a>
Expand All @@ -97,8 +99,8 @@ export default function BigNFT({
Payment Tokens ({paymentTokensToBeAdded.length})
</div>

{paymentTokensToBeAdded.map((token) => (
<div>
{paymentTokensToBeAdded.map((token, index) => (
<div key={index}>
<div className="hidden md:flex italic text-xs sm:text-sm text-left text-slate-600">
<a
href={
Expand All @@ -111,6 +113,7 @@ export default function BigNFT({
token
}
target="_blank"
rel="noreferrer"
>
{token}
</a>
Expand All @@ -127,6 +130,7 @@ export default function BigNFT({
token
}
target="_blank"
rel="noreferrer"
>
{truncateStr(token, 15)}
</a>
Expand All @@ -148,8 +152,8 @@ export default function BigNFT({
Payment Tokens ({paymentTokens.length})
</div>

{paymentTokens.map((token) => (
<div>
{paymentTokens.map((token, index) => (
<div key={index}>
<div className="hidden md:flex italic text-xs sm:text-sm text-left text-slate-600">
<a
href={
Expand All @@ -162,6 +166,7 @@ export default function BigNFT({
token.address
}
target="_blank"
rel="noreferrer"
>
<span className="font-bold">
{token.label}
Expand All @@ -181,6 +186,7 @@ export default function BigNFT({
token.address
}
target="_blank"
rel="noreferrer"
>
<span className="font-bold">
{token.label}
Expand Down
24 changes: 6 additions & 18 deletions frontend/components/web3/Listing.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
import { useEffect, useState } from "react"
import { Modal, useNotification, Select, Input } from "@web3uikit/core"
import { Modal, useNotification } from "@web3uikit/core"
import { useMoralis } from "react-moralis"
import { useCookies } from "react-cookie"
import { ethers } from "ethers"

import { getChainName } from "../../helpers/getChainName"
import nftTypes from "../../helpers/nftTypes"
import truncateStr from "../../helpers/truncateStr"

import Image from "next/image"
import { FaEthereum } from "react-icons/fa"

import retrieveTokenSymbol from "../../hooks/retrieveTokenSymbol"
import retrieveTokenAmount from "../../hooks/retrieveTokenAmount"
import retrieveTokenBalance from "../../hooks/retrieveTokenBalance"
import delistNft from "../../hooks/nftMarketplace/deListNft"
import approveNft from "../../hooks/nftMarketplace/approveNft"
import listNft from "../../hooks/nftMarketplace/listNft"
import addPaymentToken from "../../hooks/nftMarketplace/addPaymentToken"
import removePaymentToken from "../../hooks/nftMarketplace/removePaymentToken"
import buyNftEth from "../../hooks/nftMarketplace/buyNftEth"
import buyNftErc20 from "../../hooks/nftMarketplace/buyNftErc20"
import approveErc20 from "../../hooks/nftMarketplace/approveErc20"

import BigNFT from "./BigNFT"
import PriceBox from "./PriceBox"
Expand Down Expand Up @@ -244,8 +229,11 @@ export default function Listing({
</h2>
<div className="w-full p-5">
<div className="grid grid-cols-1 gap-5 lg:grid-cols-3">
{tokenURI.attributes.map((attr) => (
<div className="text-xs sm:text-sm p-2 rounded-xl border border-cyan-700 bg-cyan-100 text-center">
{tokenURI.attributes.map((attr, index) => (
<div
key={index}
className="text-xs sm:text-sm p-2 rounded-xl border border-cyan-700 bg-cyan-100 text-center"
>
<h3 className="text-cyan-700">
{capitalizeFirstLetter(attr.trait_type)}
</h3>
Expand Down
1 change: 1 addition & 0 deletions frontend/components/web3/NFT.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export default function NFT({
nftAddress
}
target="_blank"
rel="noreferrer"
>
{truncateStr(nftAddress, 15)}
</a>
Expand Down
Loading

0 comments on commit 6e67a1c

Please sign in to comment.