1- import React , { useRef } from 'react' ;
1+ import React , { useState } from 'react' ;
22import { useNotification } from '../providers/NotificationProvider' ;
3+ import { Button } from '@stellar/design-system' ;
34
45const FundAccountButton : React . FC = ( ) => {
56 const { addNotification } = useNotification ( ) ;
6- const buttonRef = useRef < HTMLButtonElement | null > ( null ) ;
7+ const [ isDisabled , setIsDisabled ] = useState ( false ) ;
78 // TODO: replace with account from wallet
89 const account = "GDVWY6R4RP37DQPAWBNQKQIZAGDVHUAYMYXKUDSY2O7PJWZNSIZIJNHQ" ;
910
1011 const handleFundAccount = async ( account : string ) => {
11- // Disable the button to prevent multiple clicks
12- if ( buttonRef . current ) {
13- buttonRef . current . disabled = true ;
14- }
12+ setIsDisabled ( true ) ;
1513
1614 addNotification ( 'Funding account, please wait…' , 'primary' ) ;
1715 try {
@@ -29,15 +27,13 @@ const FundAccountButton: React.FC = () => {
2927 console . error ( 'Error funding account:' , error ) ;
3028 addNotification ( 'Error funding account. Please try again.' , 'error' ) ;
3129 } finally {
32- if ( buttonRef . current ) {
33- buttonRef . current . disabled = false ;
34- }
30+ setIsDisabled ( false ) ;
3531 }
3632 } ;
3733
3834 return (
3935 < div >
40- < button ref = { buttonRef } onClick = { handleFundAccount . bind ( this , account ) } > Fund Account</ button >
36+ < Button disabled = { isDisabled } onClick = { handleFundAccount . bind ( this , account ) } variant = "primary" size = "md" > Fund Account</ Button >
4137 </ div >
4238 ) ;
4339} ;
0 commit comments