@@ -9,7 +9,13 @@ import { cn } from "@/lib/utils";
9
9
import { useMutation , useQuery } from "@tanstack/react-query" ;
10
10
import { TransactionButton } from "components/buttons/TransactionButton" ;
11
11
import { useTrack } from "hooks/analytics/useTrack" ;
12
- import { CheckIcon , CircleIcon , ExternalLinkIcon , XIcon } from "lucide-react" ;
12
+ import {
13
+ CheckIcon ,
14
+ CircleAlertIcon ,
15
+ CircleIcon ,
16
+ ExternalLinkIcon ,
17
+ XIcon ,
18
+ } from "lucide-react" ;
13
19
import { useTheme } from "next-themes" ;
14
20
import Link from "next/link" ;
15
21
import { useState } from "react" ;
@@ -34,6 +40,7 @@ import {
34
40
} from "thirdweb/react" ;
35
41
import { getClaimParams , maxUint256 } from "thirdweb/utils" ;
36
42
import { tryCatch } from "utils/try-catch" ;
43
+ import { ToolTipLabel } from "../../../../../../../../../../@/components/ui/tooltip" ;
37
44
import { getSDKTheme } from "../../../../../../../../components/sdk-component-theme" ;
38
45
import { PublicPageConnectButton } from "../../../_components/PublicPageConnectButton" ;
39
46
import { getCurrencyMeta } from "../../_utils/getCurrencyMeta" ;
@@ -216,23 +223,23 @@ export function ClaimTokenCardUI(props: {
216
223
} ,
217
224
} ) ;
218
225
226
+ const publicPrice = {
227
+ pricePerTokenWei : props . claimCondition . pricePerToken ,
228
+ currencyAddress : props . claimCondition . currency ,
229
+ decimals : props . claimConditionCurrency . decimals ,
230
+ symbol : props . claimConditionCurrency . symbol ,
231
+ } ;
232
+
219
233
const claimParamsQuery = useQuery ( {
220
234
queryKey : [ "claim-params" , props . contract . address , account ?. address ] ,
221
235
queryFn : async ( ) => {
222
- const defaultPricing = {
223
- pricePerTokenWei : props . claimCondition . pricePerToken ,
224
- currencyAddress : props . claimCondition . currency ,
225
- decimals : props . claimConditionCurrency . decimals ,
226
- symbol : props . claimConditionCurrency . symbol ,
227
- } ;
228
-
229
236
if ( ! account ) {
230
- return defaultPricing ;
237
+ return publicPrice ;
231
238
}
232
239
233
240
const merkleRoot = props . claimCondition . merkleRoot ;
234
241
if ( ! merkleRoot || merkleRoot === padHex ( "0x" , { size : 32 } ) ) {
235
- return defaultPricing ;
242
+ return publicPrice ;
236
243
}
237
244
238
245
const claimParams = await getClaimParams ( {
@@ -307,6 +314,11 @@ export function ClaimTokenCardUI(props: {
307
314
) ;
308
315
}
309
316
317
+ const isShowingCustomPrice =
318
+ claimParamsData &&
319
+ ( claimParamsData . pricePerTokenWei !== publicPrice . pricePerTokenWei ||
320
+ claimParamsData . currencyAddress !== publicPrice . currencyAddress ) ;
321
+
310
322
return (
311
323
< div className = "rounded-xl border bg-card " >
312
324
< div className = "border-b px-4 py-5 lg:px-5" >
@@ -342,25 +354,22 @@ export function ClaimTokenCardUI(props: {
342
354
343
355
< div className = "space-y-3 rounded-lg bg-muted/50 p-3" >
344
356
{ /* Price per token */ }
345
- < div className = "flex justify-between font-medium text-sm" >
346
- < span > Price per token</ span >
347
-
348
- < SkeletonContainer
349
- skeletonData = { `0.00 ${ props . claimConditionCurrency . symbol } ` }
350
- loadedData = {
351
- claimParamsData
352
- ? claimParamsData . pricePerTokenWei === 0n
353
- ? "FREE"
354
- : `${ toTokens (
355
- claimParamsData . pricePerTokenWei ,
356
- claimParamsData . decimals ,
357
- ) } ${ claimParamsData . symbol } `
358
- : undefined
359
- }
360
- render = { ( v ) => {
361
- return < span className = "" > { v } </ span > ;
362
- } }
363
- />
357
+ < div className = "flex items-start justify-between font-medium text-sm" >
358
+ < span className = "flex items-center gap-2" >
359
+ Price per token
360
+ { isShowingCustomPrice && (
361
+ < ToolTipLabel label = "Your connected wallet address is added in the allowlist and is getting a special price" >
362
+ < CircleAlertIcon className = "size-3.5 text-muted-foreground" />
363
+ </ ToolTipLabel >
364
+ ) }
365
+ </ span >
366
+
367
+ < div className = "flex flex-col items-end gap-1" >
368
+ { isShowingCustomPrice && (
369
+ < TokenPrice data = { publicPrice } strikethrough = { true } />
370
+ ) }
371
+ < TokenPrice data = { claimParamsData } strikethrough = { false } />
372
+ </ div >
364
373
</ div >
365
374
366
375
{ /* Quantity */ }
@@ -441,6 +450,43 @@ export function ClaimTokenCardUI(props: {
441
450
) ;
442
451
}
443
452
453
+ function TokenPrice ( props : {
454
+ strikethrough : boolean ;
455
+ data :
456
+ | {
457
+ pricePerTokenWei : bigint ;
458
+ decimals : number ;
459
+ symbol : string ;
460
+ }
461
+ | undefined ;
462
+ } ) {
463
+ return (
464
+ < SkeletonContainer
465
+ skeletonData = { "0.00 ETH" }
466
+ loadedData = {
467
+ props . data
468
+ ? props . data . pricePerTokenWei === 0n
469
+ ? "FREE"
470
+ : `${ toTokens (
471
+ props . data . pricePerTokenWei ,
472
+ props . data . decimals ,
473
+ ) } ${ props . data . symbol } `
474
+ : undefined
475
+ }
476
+ render = { ( v ) => {
477
+ if ( props . strikethrough ) {
478
+ return (
479
+ < s className = "font-medium text-muted-foreground text-sm line-through decoration-muted-foreground/50" >
480
+ { v }
481
+ </ s >
482
+ ) ;
483
+ }
484
+ return < span className = "font-medium text-foreground text-sm" > { v } </ span > ;
485
+ } }
486
+ />
487
+ ) ;
488
+ }
489
+
444
490
function SupplyRemaining ( props : {
445
491
supplyClaimed : bigint ;
446
492
maxClaimableSupply : bigint ;
0 commit comments