Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 45 additions & 13 deletions Website/pages/collection/[pageName].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,20 +142,40 @@ 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 {
checkNFTBalance.current = true;
//setExpectingUpdate(true);
fetchNFTBalance();
}
}, [assignmentData, openAssetModal, fetchNFTBalance, checkNFTBalance]);
}, [assignmentData, openAssetModal, fetchNFTBalance, checkNFTBalance, validRandoms]);

useEffect(() => {
if (!assignmentData) return;
Expand Down Expand Up @@ -235,16 +255,24 @@ 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 (
<>
<Head>
<title>Let&apos;s Cook | {pageName}</title>
</Head>
<main style={{ background: "linear-gradient(180deg, #292929 10%, #0B0B0B 100%)", height: "auto" }}>
<CollectionFeaturedBanner featuredLaunch={collection} isHomePage={false} />
<HStack align="center" spacing={0} zIndex={99} w="100%" mt={xs ? 1 : -2} className="ml-4 mt-2">
<HStack align="center" spacing={0} zIndex={99} w="100%" mt={xs ? 1 : -2} className="mt-2 ml-4">
{/* add rewards */}
{["Mint", "My NFTs", "Marketplace"].map((name, i) => {
const isActive = selected === name;
Expand Down Expand Up @@ -607,15 +635,18 @@ const CollectionSwapPage = () => {
<HStack w="100%">
{assignmentData === null || assignmentData.status > 0 ? (
<Tooltip
label={
enoughTokenBalance == false
? "You don't have enough token balance"
: hasEnoughWhitelistToken == false &&
"You don't have WhiteList token balance"
}
label={getBalanceMessage(
enoughTokenBalance,
hasEnoughWhitelistToken,
collection.num_available !== 0,
)}
hasArrow
offset={[0, 10]}
isDisabled={enoughTokenBalance && hasEnoughWhitelistToken}
isDisabled={
enoughTokenBalance &&
hasEnoughWhitelistToken &&
collection.num_available !== 0
}
>
<Button
w="100%"
Expand All @@ -633,7 +664,8 @@ const CollectionSwapPage = () => {
isDisabled={
enoughTokenBalance == false ||
hasEnoughWhitelistToken == false ||
isLoading
isLoading ||
collection.num_available === 0
}
>
Confirm {collectionPlugins.probability}
Expand Down