@@ -22,7 +22,7 @@ export function SubmitButton({ isWalletConnected, isBalanceLoaded }: ISubmitButt
22
22
const { switchNetworkAsync } = useSwitchNetwork ( )
23
23
const { openConnectModal } = useConnectModal ( )
24
24
const dispatch = useAppDispatch ( )
25
- const { errors, touched, values } = useFormikContext < SwapFormValues > ( )
25
+ const { errors, touched, values, isSubmitting } = useFormikContext < SwapFormValues > ( )
26
26
27
27
const switchToNetwork = useCallback ( async ( ) => {
28
28
try {
@@ -93,10 +93,12 @@ export function SubmitButton({ isWalletConnected, isBalanceLoaded }: ISubmitButt
93
93
return undefined
94
94
} , [ isWalletConnected , isOnCelo , openConnectModal , switchToNetwork ] )
95
95
96
- const isDisabled =
97
- buttonText === Button3DText . balanceStillLoading
98
- ? isWalletConnected && ! hasError
99
- : isWalletConnected && ! Number ( values . quote ) && ! hasError
96
+ const isDisabled = useMemo ( ( ) => {
97
+ if ( ! isWalletConnected || hasError ) return false
98
+ if ( buttonText === Button3DText . balanceStillLoading ) return true
99
+ if ( isSubmitting ) return true
100
+ return ! Number ( values . quote )
101
+ } , [ isWalletConnected , hasError , buttonText , values . quote , isSubmitting ] )
100
102
101
103
return (
102
104
< div className = "flex flex-col items-center justify-center w-full" >
@@ -109,7 +111,7 @@ export function SubmitButton({ isWalletConnected, isBalanceLoaded }: ISubmitButt
109
111
isWalletConnected = { isWalletConnected }
110
112
isBalanceLoaded = { isBalanceLoaded }
111
113
>
112
- { buttonText }
114
+ { isSubmitting ? 'Loading...' : buttonText }
113
115
</ Button3D >
114
116
</ div >
115
117
)
0 commit comments