Skip to content

Commit

Permalink
Fix wrong error message (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoiacovino authored Sep 28, 2022
1 parent 9376192 commit 2ddbd8c
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 7 deletions.
21 changes: 20 additions & 1 deletion src/shared/claim-button-erc1155.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import {
useActiveClaimCondition,
useAddress,
useClaimConditions,
useClaimIneligibilityReasons,
useTotalCirculatingSupply,
Web3Button,
Expand Down Expand Up @@ -45,6 +46,7 @@ export const ERC1155ClaimButton: React.FC<ClaimButtoProps> = ({

const debouncedQuantity = useDebounce(quantity, 500);

const claimConditions = useClaimConditions(contract);
const activeClaimCondition = useActiveClaimCondition(contract, tokenId);

const claimIneligibilityReasons = useClaimIneligibilityReasons(
Expand Down Expand Up @@ -234,14 +236,31 @@ export const ERC1155ClaimButton: React.FC<ClaimButtoProps> = ({
const colors = chakraTheme.colors;
const accentColor = colors[primaryColor as keyof typeof colors][500];

if (activeClaimCondition.isError) {
if (
claimConditions.data?.length === 0 ||
claimConditions.data?.every((cc) => cc.maxQuantity === "0")
) {
return (
<Text size="label.md" color="red.500">
This drop is not ready to be minted yet. (No claim condition set)
</Text>
);
}

if (
(claimConditions.data &&
claimConditions.data.length > 0 &&
activeClaimCondition.isError) ||
(activeClaimCondition.data &&
activeClaimCondition.data.startTime > new Date())
) {
return (
<Text size="label.md" color={`${primaryColor}.500`}>
Drop is starting soon. Please check back later.
</Text>
);
}

return (
<Stack spacing={4} align="center" w="100%">
<Flex
Expand Down
21 changes: 20 additions & 1 deletion src/shared/claim-button-erc20.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import {
useActiveClaimCondition,
useAddress,
useClaimConditions,
useClaimIneligibilityReasons,
Web3Button,
} from "@thirdweb-dev/react";
Expand Down Expand Up @@ -42,6 +43,7 @@ export const ERC20ClaimButton: React.FC<ClaimButtoProps> = ({

const debouncedQuantity = useDebounce(quantity, 500);

const claimConditions = useClaimConditions(contract);
const activeClaimCondition = useActiveClaimCondition(contract);
const claimIneligibilityReasons = useClaimIneligibilityReasons(contract, {
quantity: debouncedQuantity,
Expand Down Expand Up @@ -198,14 +200,31 @@ export const ERC20ClaimButton: React.FC<ClaimButtoProps> = ({
const colors = chakraTheme.colors;
const accentColor = colors[primaryColor as keyof typeof colors][500];

if (activeClaimCondition.isError) {
if (
claimConditions.data?.length === 0 ||
claimConditions.data?.every((cc) => cc.maxQuantity === "0")
) {
return (
<Text size="label.md" color="red.500">
This drop is not ready to be minted yet. (No claim condition set)
</Text>
);
}

if (
(claimConditions.data &&
claimConditions.data.length > 0 &&
activeClaimCondition.isError) ||
(activeClaimCondition.data &&
activeClaimCondition.data.startTime > new Date())
) {
return (
<Text size="label.md" color={`${primaryColor}.500`}>
Drop is starting soon. Please check back later.
</Text>
);
}

return (
<Stack spacing={4} align="center" w="100%">
<Flex
Expand Down
22 changes: 21 additions & 1 deletion src/shared/claim-button-erc721.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import {
useActiveClaimCondition,
useAddress,
useClaimConditions,
useClaimedNFTSupply,
useClaimIneligibilityReasons,
useUnclaimedNFTSupply,
Expand Down Expand Up @@ -44,6 +45,7 @@ export const ERC721ClaimButton: React.FC<ClaimButtoProps> = ({

const debouncedQuantity = useDebounce(quantity, 500);

const claimConditions = useClaimConditions(contract);
const activeClaimCondition = useActiveClaimCondition(contract);
const claimIneligibilityReasons = useClaimIneligibilityReasons(contract, {
quantity: debouncedQuantity,
Expand Down Expand Up @@ -223,14 +225,32 @@ export const ERC721ClaimButton: React.FC<ClaimButtoProps> = ({

const colors = chakraTheme.colors;
const accentColor = colors[primaryColor as keyof typeof colors][500];
if (activeClaimCondition.isError) {

if (
claimConditions.data?.length === 0 ||
claimConditions.data?.every((cc) => cc.maxQuantity === "0")
) {
return (
<Text size="label.md" color="red.500">
This drop is not ready to be minted yet. (No claim condition set)
</Text>
);
}

if (
(claimConditions.data &&
claimConditions.data.length > 0 &&
activeClaimCondition.isError) ||
(activeClaimCondition.data &&
activeClaimCondition.data.startTime > new Date())
) {
return (
<Text size="label.md" color={`${primaryColor}.500`}>
Drop is starting soon. Please check back later.
</Text>
);
}

return (
<Stack spacing={4} align="center" w="100%">
<Flex
Expand Down
8 changes: 4 additions & 4 deletions src/utils/parseIneligibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ export function parseIneligibility(
reason === ClaimEligibility.NoActiveClaimPhase ||
reason === ClaimEligibility.NoClaimConditionSet
) {
return "This drop is not ready to be claimed.";
return "This drop is not ready to be minted.";
} else if (reason === ClaimEligibility.NotEnoughTokens) {
return "You don't have enough currency to claim.";
return "You don't have enough currency to mint.";
} else if (reason === ClaimEligibility.AddressNotAllowed) {
if (quantity > 1) {
return `You are not eligible to claim ${quantity} tokens.`;
return `You are not eligible to mint ${quantity} tokens.`;
}

return "You are not eligible to claim at this time.";
return "You are not eligible to mint at this time.";
}

return reason;
Expand Down

0 comments on commit 2ddbd8c

Please sign in to comment.