diff --git a/Website/pages/collection/[pageName].tsx b/Website/pages/collection/[pageName].tsx index a2ba9288..c0a0f89f 100644 --- a/Website/pages/collection/[pageName].tsx +++ b/Website/pages/collection/[pageName].tsx @@ -142,12 +142,32 @@ const CollectionSwapPage = () => { sm_checking_w: 420, }; + useEffect(() => { + if (assignmentData?.status === 2) { + openAssetModal(); + } + + if (assignmentData?.status === 1) { + openAssetModal(); + } + }, [isMintLoading, isMintRandomLoading]); + const updateAssignment = useCallback(async () => { // if we are started to wait for randoms then open up the modal if (!assignmentData.random_address.equals(SYSTEM_KEY)) { - openAssetModal(); + if (validRandoms) { + if (assignmentData.status === 0) { + if (collection.collection_meta["__kind"] === "RandomFixedSupply") { + MintNFT(); + } + if (collection.collection_meta["__kind"] === "RandomUnlimited") { + MintRandom(); + } + } + } } + if (assignmentData.status < 2) { return; } else { @@ -155,7 +175,7 @@ const CollectionSwapPage = () => { //setExpectingUpdate(true); fetchNFTBalance(); } - }, [assignmentData, openAssetModal, fetchNFTBalance, checkNFTBalance]); + }, [assignmentData, openAssetModal, fetchNFTBalance, checkNFTBalance, validRandoms]); useEffect(() => { if (!assignmentData) return; @@ -235,8 +255,16 @@ const CollectionSwapPage = () => { ? whiteListTokenBalance >= bignum_to_num(collectionPlugins.whitelistAmount) / Math.pow(10, whiteListDecimals) : true; - //console.log(collection.keys[CollectionKeys.TeamWallet].toString()) - //console.log(whiteListTokenBalance, "whiteListTokenBalance >= collectionPlugins.whitelistAmount", enoughTokenBalance); + function getBalanceMessage(enoughTokenBalance, hasEnoughWhitelistToken, hasEnoughCollection) { + if (!enoughTokenBalance) { + return "You don't have enough token balance"; + } else if (!hasEnoughWhitelistToken) { + return "You don't have WhiteList token balance"; + } else if (!hasEnoughCollection) { + return "There are no supplies left"; + } + return ""; // Return an empty string if both conditions are satisfied + } return ( <> @@ -244,7 +272,7 @@ const CollectionSwapPage = () => {
- + {/* add rewards */} {["Mint", "My NFTs", "Marketplace"].map((name, i) => { const isActive = selected === name; @@ -607,15 +635,18 @@ const CollectionSwapPage = () => { {assignmentData === null || assignmentData.status > 0 ? (