-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ef876f
commit 7310c2e
Showing
4 changed files
with
86 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,45 @@ | ||
import { useEffect, useState } from "react"; | ||
|
||
export function useGetAllMetadatas(contract: any, mintCount: bigint) { | ||
const [data, setData] = useState<any[]>([]); | ||
const [data, setData] = useState<any[]>([]); | ||
|
||
useEffect(()=> { | ||
async function get() { | ||
const arr = []; | ||
for (let i = 0; i < mintCount; i++) { | ||
let result = await contract?.read.tokenURI([i]); | ||
arr.push(result); | ||
} | ||
useEffect(() => { | ||
async function get() { | ||
const arr = []; | ||
for (let i = 0; i < mintCount; i++) { | ||
let result = await contract?.read.tokenURI([i]); | ||
arr.push(result); | ||
} | ||
|
||
setData([...arr]); | ||
} | ||
get(); | ||
}, [contract?.address, mintCount]) | ||
setData([...arr]); | ||
} | ||
get(); | ||
}, [contract?.address, mintCount]); | ||
|
||
return { data } | ||
return { data }; | ||
} | ||
|
||
export function useFetches(uris: string[]) { | ||
const [data, setData] = useState<any[]>([]); | ||
|
||
useEffect(() => { | ||
async function get() { | ||
const arr = []; | ||
for (let i = 0; i < uris.length; i++) { | ||
try { | ||
const response = await fetch(uris[i]); | ||
const responseJson = await response.json(); | ||
arr.push(responseJson); | ||
} | ||
catch (e) { | ||
console.log('Could not fetch URI'); | ||
arr.push({}); | ||
} | ||
const [data, setData] = useState<any[]>([]); | ||
|
||
useEffect(() => { | ||
async function get() { | ||
const arr = []; | ||
for (let i = 0; i < uris.length; i++) { | ||
try { | ||
const response = await fetch(uris[i]); | ||
const responseJson = await response.json(); | ||
arr.push(responseJson); | ||
} catch (e) { | ||
console.log("Could not fetch URI"); | ||
arr.push({}); | ||
} | ||
|
||
setData([...arr]); | ||
} | ||
get(); | ||
}, [uris]); | ||
|
||
return { data }; | ||
} | ||
|
||
setData([...arr]); | ||
} | ||
get(); | ||
}, [uris]); | ||
|
||
return { data }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,31 @@ | ||
interface Nft { | ||
name?: string; | ||
description?: string; | ||
image?: string; | ||
name?: string; | ||
description?: string; | ||
image?: string; | ||
} | ||
|
||
interface NftCardProps { | ||
nft: Nft; | ||
nft: Nft; | ||
} | ||
|
||
export function NftCard (props: NftCardProps) { | ||
export function NftCard(props: NftCardProps) { | ||
if (props.nft && props.nft.image) { | ||
props.nft.image = props.nft.image.replace("ipfs://", "https://ipfs.io/ipfs/"); | ||
} | ||
|
||
if (props.nft && props.nft.image){ | ||
props.nft.image = props.nft.image.replace("ipfs://", "https://ipfs.io/ipfs/"); | ||
} | ||
//flex flex-col items-center justify-center text-center bg-black max-w-xs rounded-lg bg-sky-900 m-1 | ||
return ( | ||
<div className="flex flex-col items-center justify-center text-center bg-black rounded-lg bg-sky-900 m-5"> | ||
<div className="m-4"> | ||
<p className="m-0 font-bold">Name</p> | ||
<p className="m-0 text-xl">{props.nft.name}</p> | ||
</div> | ||
|
||
//flex flex-col items-center justify-center text-center bg-black max-w-xs rounded-lg bg-sky-900 m-1 | ||
return ( | ||
<div className="flex flex-col items-center justify-center text-center bg-black rounded-lg bg-sky-900 m-5"> | ||
|
||
<div className="m-4"> | ||
<p className="m-0 font-bold">Name</p> | ||
<p className="m-0 text-xl">{ props.nft.name}</p> | ||
</div> | ||
|
||
<img className="rounded-lg" src={props.nft.image} width={128} height={128}/> | ||
<div className="m-4"> | ||
<p className="m-0 font-bold text-size-xl">Description</p> | ||
<p className="m-0 text-xs"> { props.nft.description}</p> | ||
</div> | ||
</div> | ||
) | ||
} | ||
<img className="rounded-lg" src={props.nft.image} width={128} height={128} /> | ||
<div className="m-4"> | ||
<p className="m-0 font-bold text-size-xl">Description</p> | ||
<p className="m-0 text-xs"> {props.nft.description}</p> | ||
</div> | ||
</div> | ||
); | ||
} |