@@ -43,6 +43,7 @@ import { useFormatedValue } from "../shared/tokenHooks";
4343import  {  useAddress  }  from  "../shared/useAddress" ; 
4444import  {  useConnectors  }  from  "../shared/useConnectors" ; 
4545import  {  useSDKWithSigner  }  from  "../shared/useSdkWithSigner" ; 
46+ import  {  parseError  }  from  "src/shared/parseError" ; 
4647
4748interface  DropWidgetProps  { 
4849  startingTab ?: "claim"  |  "inventory" ; 
@@ -223,26 +224,19 @@ const ClaimButton: React.FC<ClaimPageProps> = ({
223224      return  module . claim ( quantity ) ; 
224225    } , 
225226    { 
226-       onSuccess : ( )  =>  queryClient . invalidateQueries ( ) , 
227+       onSuccess : ( )  =>  { 
228+         queryClient . invalidateQueries ( ) 
229+         toast ( { 
230+           title : "Successfuly claimed." , 
231+           status : "success" , 
232+           duration : 5000 , 
233+           isClosable : true , 
234+         } ) ; 
235+       } , 
227236      onError : ( err )  =>  { 
228-         const  anyErr  =  err  as  any ; 
229-         let  message  =  "" ; 
230- 
231-         if  ( anyErr . code  ===  "INSUFFICIENT_FUNDS" )  { 
232-           message  =  "Insufficient funds to mint" ; 
233-         }  else  if  ( anyErr . code  ===  "UNPREDICTABLE_GAS_LIMIT" )  { 
234-           if  ( anyErr . message . includes ( "exceed max mint supply" ) )  { 
235-             message  =  "You are not eligible to mint right now" ; 
236-           } 
237-         }  else  if  ( anyErr . message . includes ( "User denied transaction signature" ) )  { 
238-           message  =  "You denied the transaction" ; 
239-         }  else  { 
240-           message  =  "You may be ineligible to claim this drop" 
241-         } 
242- 
243237        toast ( { 
244238          title : "Failed to claim drop." , 
245-           description : message , 
239+           description : parseError ( err ) , 
246240          status : "error" , 
247241          duration : 9000 , 
248242          isClosable : true , 
@@ -492,16 +486,14 @@ const DropWidget: React.FC<DropWidgetProps> = ({
492486    {  enabled : ! ! dropModule  } , 
493487  ) ; 
494488
495-   const  isSoldOut  =  totalAvailable . data ?. gte ( available . data  ||  0 ) ; 
496- 
497-   const  onlyOnce  =  useRef ( true ) ; 
489+   const  isNotSoldOut  =  totalAvailable . data ?. gte ( available . data  ||  0 ) ; 
498490
491+   const  numOwned  =  BigNumber . from ( owned . data  ||  0 ) . toNumber ( ) ; 
499492  useEffect ( ( )  =>  { 
500-     if  ( owned . data ?. gt ( 0 )  &&  isSoldOut  &&  onlyOnce . current )  { 
501-       onlyOnce . current  =  false ; 
493+     if  ( owned . data ?. gt ( 0 )  &&  isNotSoldOut )  { 
502494      setActiveTab ( "inventory" ) ; 
503495    } 
504-   } ,  [ owned . data ,   isSoldOut ] ) ; 
496+   } ,  [ numOwned ,   isNotSoldOut ] ) ; 
505497
506498  return  ( 
507499    < Flex 
0 commit comments