Skip to content

Commit 2ddbd8c

Browse files
Fix wrong error message (#75)
1 parent 9376192 commit 2ddbd8c

File tree

4 files changed

+65
-7
lines changed

4 files changed

+65
-7
lines changed

src/shared/claim-button-erc1155.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
import {
1616
useActiveClaimCondition,
1717
useAddress,
18+
useClaimConditions,
1819
useClaimIneligibilityReasons,
1920
useTotalCirculatingSupply,
2021
Web3Button,
@@ -45,6 +46,7 @@ export const ERC1155ClaimButton: React.FC<ClaimButtoProps> = ({
4546

4647
const debouncedQuantity = useDebounce(quantity, 500);
4748

49+
const claimConditions = useClaimConditions(contract);
4850
const activeClaimCondition = useActiveClaimCondition(contract, tokenId);
4951

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

237-
if (activeClaimCondition.isError) {
239+
if (
240+
claimConditions.data?.length === 0 ||
241+
claimConditions.data?.every((cc) => cc.maxQuantity === "0")
242+
) {
238243
return (
239244
<Text size="label.md" color="red.500">
240245
This drop is not ready to be minted yet. (No claim condition set)
241246
</Text>
242247
);
243248
}
244249

250+
if (
251+
(claimConditions.data &&
252+
claimConditions.data.length > 0 &&
253+
activeClaimCondition.isError) ||
254+
(activeClaimCondition.data &&
255+
activeClaimCondition.data.startTime > new Date())
256+
) {
257+
return (
258+
<Text size="label.md" color={`${primaryColor}.500`}>
259+
Drop is starting soon. Please check back later.
260+
</Text>
261+
);
262+
}
263+
245264
return (
246265
<Stack spacing={4} align="center" w="100%">
247266
<Flex

src/shared/claim-button-erc20.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
import {
1616
useActiveClaimCondition,
1717
useAddress,
18+
useClaimConditions,
1819
useClaimIneligibilityReasons,
1920
Web3Button,
2021
} from "@thirdweb-dev/react";
@@ -42,6 +43,7 @@ export const ERC20ClaimButton: React.FC<ClaimButtoProps> = ({
4243

4344
const debouncedQuantity = useDebounce(quantity, 500);
4445

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

201-
if (activeClaimCondition.isError) {
203+
if (
204+
claimConditions.data?.length === 0 ||
205+
claimConditions.data?.every((cc) => cc.maxQuantity === "0")
206+
) {
202207
return (
203208
<Text size="label.md" color="red.500">
204209
This drop is not ready to be minted yet. (No claim condition set)
205210
</Text>
206211
);
207212
}
208213

214+
if (
215+
(claimConditions.data &&
216+
claimConditions.data.length > 0 &&
217+
activeClaimCondition.isError) ||
218+
(activeClaimCondition.data &&
219+
activeClaimCondition.data.startTime > new Date())
220+
) {
221+
return (
222+
<Text size="label.md" color={`${primaryColor}.500`}>
223+
Drop is starting soon. Please check back later.
224+
</Text>
225+
);
226+
}
227+
209228
return (
210229
<Stack spacing={4} align="center" w="100%">
211230
<Flex

src/shared/claim-button-erc721.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
import {
1616
useActiveClaimCondition,
1717
useAddress,
18+
useClaimConditions,
1819
useClaimedNFTSupply,
1920
useClaimIneligibilityReasons,
2021
useUnclaimedNFTSupply,
@@ -44,6 +45,7 @@ export const ERC721ClaimButton: React.FC<ClaimButtoProps> = ({
4445

4546
const debouncedQuantity = useDebounce(quantity, 500);
4647

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

224226
const colors = chakraTheme.colors;
225227
const accentColor = colors[primaryColor as keyof typeof colors][500];
226-
if (activeClaimCondition.isError) {
228+
229+
if (
230+
claimConditions.data?.length === 0 ||
231+
claimConditions.data?.every((cc) => cc.maxQuantity === "0")
232+
) {
227233
return (
228234
<Text size="label.md" color="red.500">
229235
This drop is not ready to be minted yet. (No claim condition set)
230236
</Text>
231237
);
232238
}
233239

240+
if (
241+
(claimConditions.data &&
242+
claimConditions.data.length > 0 &&
243+
activeClaimCondition.isError) ||
244+
(activeClaimCondition.data &&
245+
activeClaimCondition.data.startTime > new Date())
246+
) {
247+
return (
248+
<Text size="label.md" color={`${primaryColor}.500`}>
249+
Drop is starting soon. Please check back later.
250+
</Text>
251+
);
252+
}
253+
234254
return (
235255
<Stack spacing={4} align="center" w="100%">
236256
<Flex

src/utils/parseIneligibility.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ export function parseIneligibility(
1515
reason === ClaimEligibility.NoActiveClaimPhase ||
1616
reason === ClaimEligibility.NoClaimConditionSet
1717
) {
18-
return "This drop is not ready to be claimed.";
18+
return "This drop is not ready to be minted.";
1919
} else if (reason === ClaimEligibility.NotEnoughTokens) {
20-
return "You don't have enough currency to claim.";
20+
return "You don't have enough currency to mint.";
2121
} else if (reason === ClaimEligibility.AddressNotAllowed) {
2222
if (quantity > 1) {
23-
return `You are not eligible to claim ${quantity} tokens.`;
23+
return `You are not eligible to mint ${quantity} tokens.`;
2424
}
2525

26-
return "You are not eligible to claim at this time.";
26+
return "You are not eligible to mint at this time.";
2727
}
2828

2929
return reason;

0 commit comments

Comments
 (0)