33import { Flex , FormControl , Input } from "@chakra-ui/react" ;
44import { TransactionButton } from "components/buttons/TransactionButton" ;
55import { useTrack } from "hooks/analytics/useTrack" ;
6- import { useTxNotifications } from "hooks/useTxNotifications" ;
76import { useForm } from "react-hook-form" ;
87import { toast } from "sonner" ;
98import { type ThirdwebContract , ZERO_ADDRESS } from "thirdweb" ;
@@ -23,13 +22,6 @@ const ClaimTabERC1155: React.FC<ClaimTabProps> = ({ contract, tokenId }) => {
2322 const form = useForm < { to : string ; amount : string } > ( {
2423 defaultValues : { amount : "1" , to : address } ,
2524 } ) ;
26-
27- const { onSuccess, onError } = useTxNotifications (
28- "Claimed successfully" ,
29- "Failed to claim" ,
30- contract ,
31- ) ;
32-
3325 const sendAndConfirmTx = useSendAndConfirmTransaction ( ) ;
3426 const account = useActiveAccount ( ) ;
3527 return (
@@ -59,28 +51,34 @@ const ClaimTabERC1155: React.FC<ClaimTabProps> = ({ contract, tokenId }) => {
5951 account,
6052 } ) ;
6153 if ( approveTx ) {
62- try {
63- await sendAndConfirmTx . mutateAsync ( approveTx ) ;
64- } catch {
65- return toast . error ( "Error approving ERC20 token" ) ;
66- }
54+ const approvalPromise = sendAndConfirmTx . mutateAsync ( approveTx ) ;
55+ toast . promise ( approvalPromise , {
56+ loading : "Approving ERC20 token for this claim" ,
57+ success : "Approved succesfully" ,
58+ error : "Failed to approve ERC20" ,
59+ } ) ;
60+ await approvalPromise ;
6761 }
68- await sendAndConfirmTx . mutateAsync ( transaction ) ;
62+ const promise = sendAndConfirmTx . mutateAsync ( transaction ) ;
63+ toast . promise ( promise , {
64+ loading : "Claiming NFT" ,
65+ success : "NFT claimed successfully" ,
66+ error : "Failed to claim NFT" ,
67+ } ) ;
6968 trackEvent ( {
7069 category : "nft" ,
7170 action : "claim" ,
7271 label : "success" ,
7372 } ) ;
74- onSuccess ( ) ;
7573 form . reset ( ) ;
7674 } catch ( error ) {
75+ console . error ( error ) ;
7776 trackEvent ( {
7877 category : "nft" ,
7978 action : "claim" ,
8079 label : "error" ,
8180 error,
8281 } ) ;
83- onError ( error ) ;
8482 }
8583 } ) }
8684 >
0 commit comments