diff --git a/apps/Mintbase/widget/Mintbase/App/NFTDetails/Index.jsx b/apps/Mintbase/widget/Mintbase/App/NFTDetails/Index.jsx index ee1c8ab3..b97f56b9 100644 --- a/apps/Mintbase/widget/Mintbase/App/NFTDetails/Index.jsx +++ b/apps/Mintbase/widget/Mintbase/App/NFTDetails/Index.jsx @@ -1,10 +1,16 @@ const { isDarkModeOn, accountId, connectedDao } = props; + +const { getAllTokens } = VM.require( + "${config_account}/widget/Mintbase.utils.get_all_tokens" +); const metadataId = props.metadataId || "nft.herewallet.near:d96acabbdb8bc6ad1317385be84030ed"; const extractedContactId = metadataId.split(":")[0]; const contractId = props.contractId || extractedContactId || "nft.herewallet.near"; +const [myToken, setMyToken] = useState(""); + const buySvg = ( { dataNFT: response2.body.data.mb_views_active_listings, }); }; -fetchNFTData(contractId); -fetchStoreFrontData(metadataId); +useEffect(() => { + fetchNFTData(contractId); + fetchStoreFrontData(metadataId); +}, []); + +useEffect(() => { + const user = context.accountId; + getAllTokens({ + metadataId, + limit: 50, + offset: 0, + search_fields: [ + { + owner: { + _ilike: `%${user}%`, + }, + }, + { + token_id: { + _ilike: `%${user}%`, + }, + }, + ], + }) + .then(({ data }) => { + const { tokens, totalTokensCount, errors } = data; + if (errors) { + console.error(errors); + } + // setCountNFTs(totalRecords); + // setLoading(fale); + setMyToken(tokens); + }) + .catch((error) => { + console.error(error); + }); +}, [metadataId]); const isMintedContract = ["mintbase1.near", "mintspace2.testnet"].some( (substring) => contractId?.includes(substring) ); return ( <> - {state.infoNFT.owner == context.accountId && ( - -
- {isMintedContract ? ( - <> - - - - ) : ( - <> - )} - - -
- - )} + {state.infoNFT.owner == context.accountId || + (myToken.length && ( + +
+ {isMintedContract ? ( + <> + + + + ) : ( + <> + )} + + +
+
+ ))} {modalState !== "" && (
@@ -316,6 +361,7 @@ return ( NftCount: state.NftCount, listingCount: state.listingCount, connectedDao: connectedDao, + usersTokens: myToken, }} /> {data?.nft_contract_id} - {/* + Owner - {data?.owner} + + {usersTokens + ? `${usersTokens[0].owner} (${usersTokens[0].token_id})` + : data.owner} + - */} + + Total Minted {NftCount} diff --git a/apps/Mintbase/widget/Mintbase/NFT/Index.jsx b/apps/Mintbase/widget/Mintbase/NFT/Index.jsx index a201c5f5..c708dc47 100644 --- a/apps/Mintbase/widget/Mintbase/NFT/Index.jsx +++ b/apps/Mintbase/widget/Mintbase/NFT/Index.jsx @@ -423,8 +423,40 @@ const NFTCard = ({ data, isDarkModeOn, accountId, connectedDao }) => { "https://ipfs.near.social/ipfs/bafkreiajgp5bmkidwesy2d6tsbdkhyfzjtom2wse2sjcwii227lt5audvq"; return ( <> - - + + + +
+ +
+ +
+ {data?.owner || data?.minter === context.accountId ? ( +
+ + +
+ ) : data?.minter === connectedDao?.address && + connectedDao?.permission ? ( +
+ +
+ ) : ( + "" + )} +
+
{ }, })} > -
- -
- -
- {data?.owner || data?.minter === context.accountId ? ( + +

{data?.nft_contract_id}

- - + +

+ {data?.title?.length > 35 + ? `${data?.title?.substring(0, 35)}...` + : data?.title} +

+ +

+ {data.price + ? data.currency === "near" + ? YoctoToNear(data.price) + : (data?.price / 1000000).toFixed(2) + : "-"} + {listingType[data?.currency]} +

- ) : data?.minter === connectedDao?.address && - connectedDao?.permission ? ( -
- +
+ + + +

{data?.price ? "1/1" : "Not Listed"}

- ) : ( - "" - )} -
- - - -

{data?.nft_contract_id}

-
- -

- {data?.title?.length > 35 - ? `${data?.title?.substring(0, 35)}...` - : data?.title} -

- -

- {data.price - ? data.currency === "near" - ? YoctoToNear(data.price) - : (data?.price / 1000000).toFixed(2) - : "-"} - {listingType[data?.currency]} -

-
-
- - + + + {modalState !== "" && ( +
+ + + {modalState === "SELL" && ( + setModalState(""), + }} /> - -

{data?.price ? "1/1" : "Not Listed"}

-
- - - - - {modalState !== "" && ( -
- - - {modalState === "SELL" && ( - setModalState(""), - }} - /> - )} - {modalState === "TRANSFER" && ( - setModalState(""), - }} - /> - )} - {modalState === "BURN" && ( - setModalState(""), - }} - /> - )} - {modalState === "MULTIPLY" && ( - setModalState(""), - }} - /> - )} - {modalState === "REMOVE" && ( - setModalState(""), - }} - /> - )} - {modalState === "OPTIONS" && ( - - -

Actions

-

setModalState("")}>X

-
- -
-
setModalState("SELL")} - className="content" - > - {pinSvg}

Sell

-
-
setModalState("TRANSFER")} - className="content" - > - {arrowSvg}

Transfer

-
- {isMintedContract && ( - <> -
setModalState("MULTIPLY")} - className="content" - > - {multiplySvg}

Multiply

-
-
setModalState("BURN")} - className="content" - > - {burnSvg}

Burn

-
- - )} -
setModalState("REMOVE")} - className="content" - > - {cancelSvg}

Remove Listing

+ )} + {modalState === "TRANSFER" && ( + setModalState(""), + }} + /> + )} + {modalState === "BURN" && ( + setModalState(""), + }} + /> + )} + {modalState === "MULTIPLY" && ( + setModalState(""), + }} + /> + )} + {modalState === "REMOVE" && ( + setModalState(""), + }} + /> + )} + {modalState === "OPTIONS" && ( + + +

Actions

+

setModalState("")}>X

+
+ +
+
setModalState("SELL")} + className="content" + > + {pinSvg}

Sell

+
+
setModalState("TRANSFER")} + className="content" + > + {arrowSvg}

Transfer

+
+ {isMintedContract && ( + <> +
setModalState("MULTIPLY")} + className="content" + > + {multiplySvg}

Multiply

+
+
setModalState("BURN")} + className="content" + > + {burnSvg}

Burn

+
+ + )} +
setModalState("REMOVE")} + className="content" + > + {cancelSvg}

Remove Listing

+
-
- - - - - - )} - -
- )} +
+ + + +
+ )} +
+
+ )} ); }; diff --git a/apps/Mintbase/widget/Mintbase/utils/get_all_tokens.jsx b/apps/Mintbase/widget/Mintbase/utils/get_all_tokens.jsx new file mode 100644 index 00000000..fee782b9 --- /dev/null +++ b/apps/Mintbase/widget/Mintbase/utils/get_all_tokens.jsx @@ -0,0 +1,62 @@ +/* +This is an example snippet - you should consider tailoring it +to your service. +*/ + +function fetchGraphQL(operationsDoc, operationName, variables) { + return asyncFetch("https://graph.mintbase.xyz/mainnet", { + method: "POST", + headers: { + "mb-api-key": "anon", + "Content-Type": "application/json", + }, + body: JSON.stringify({ + query: operationsDoc, + variables: variables, + operationName: operationName, + }), + }).then((result) => result.body); +} + +const operationsDoc = ` + query v2_omnisite_GetAllTokensQuery($metadataId: String!, $limit: Int, $offset: Int, $search_fields: [mb_views_nft_tokens_with_listing_bool_exp!]) { + tokens: mb_views_nft_tokens_with_listing( + order_by: {price: asc_nulls_last} + where: {metadata_id: {_eq: $metadataId}, _or: $search_fields} + limit: $limit + offset: $offset + ) { + title + token_id + price + owner + nft_contract_id + market_id + currency + listing_kind + } + totalTokensCount: mb_views_nft_tokens_with_listing_aggregate( + where: {metadata_id: {_eq: $metadataId}, _or: $search_fields} + ) { + aggregate { + count + } + } + } +`; + +function getAllTokens({ + metadataId, + limit, + offset, + search_fields, +}) { + return fetchGraphQL(operationsDoc, "v2_omnisite_GetAllTokensQuery", { + metadataId: metadataId, + limit: limit, + offset: offset, + search_fields: search_fields, + }); +} + +return { getAllTokens };