diff --git a/src/pages/MyListed.tsx b/src/pages/MyListed.tsx index f7151efa..dfd8fa12 100644 --- a/src/pages/MyListed.tsx +++ b/src/pages/MyListed.tsx @@ -37,8 +37,8 @@ export const MyListed = () => { async function fetchDataNfts() { setIsNftLoading(true); - - const _dataNfts: DataNft[] = await DataNft.createManyFromApi(offers.map((offer) => offer.offeredTokenNonce)); + const nonces: number[] = offers.map((offer) => offer.offeredTokenNonce); + const _dataNfts: DataNft[] = await DataNft.createManyFromApi(nonces); console.log("_dataNfts", _dataNfts); setDataNfts(_dataNfts); @@ -52,6 +52,8 @@ export const MyListed = () => { }, [address, hasPendingTransactions]); useEffect(() => { + if (!offers.length) return; + fetchDataNfts(); }, [offers]); @@ -68,37 +70,36 @@ export const MyListed = () => {
{offers.length > 0 ? ( offers.map((offer, index) => { - const isDataNftLoaded = !isNftLoading && dataNfts.length > index; + const isDataNftLoaded = !isNftLoading; const nftId = createNftId(offer.offeredTokenIdentifier, offer.offeredTokenNonce); - - return ( -
-
-
-
- -
- -
-
Offer Detail
-
-
- Identifier: - - {nftId} - - - - -
-
- Listed: - {offer.quantity} -
- {/*
+ const dataNft = dataNfts.find((nft) => nft.tokenIdentifier == nftId); + + if (dataNft) { + return ( +
+
+
+
+ +
+ +
+
Offer Detail
+
+
+ Identifier: + + {nftId} + + + + +
+
+ Listed: + {offer.quantity} +
+ {/*
Wanting: {convertWeiToEsdt( @@ -108,42 +109,42 @@ export const MyListed = () => {
*/} -
-
Data NFT Detail
-
-
- Title: - {isDataNftLoaded && dataNfts[index].title} -
-
- Description: - - {isDataNftLoaded && - (dataNfts[index].description.length > 20 ? dataNfts[index].description.slice(0, 20) + " ..." : dataNfts[index].description)} - -
-
- Creator: - - {isDataNftLoaded && } - -
-
- Created At: - {isDataNftLoaded && dataNfts[index].creationTime.toLocaleString()} -
-
- Total Supply: - {isDataNftLoaded && dataNfts[index].supply} -
-
- Royalties: - {isDataNftLoaded && `${convertToLocalString(dataNfts[index].royalties * 100, 2)}%`} +
+
Data NFT Detail
+
+
+ Title: + {isDataNftLoaded && dataNft.title} +
+
+ Description: + + {isDataNftLoaded && (dataNft.description.length > 20 ? dataNft?.description.slice(0, 20) + " ..." : dataNft.description)} + +
+
+ Creator: + + {isDataNftLoaded && } + +
+
+ Created At: + {isDataNftLoaded && dataNft.creationTime.toLocaleString()} +
+
+ Total Supply: + {isDataNftLoaded && dataNft.supply} +
+
+ Royalties: + {isDataNftLoaded && `${convertToLocalString(dataNft.royalties * 100, 2)}%`} +
-
- ); + ); + } }) ) : (

You do not have any listed Data NFTs offers.