diff --git a/components/common/MainActionButton/index.tsx b/components/common/MainActionButton/index.tsx index 279e8acf3..0972341c8 100644 --- a/components/common/MainActionButton/index.tsx +++ b/components/common/MainActionButton/index.tsx @@ -1,4 +1,4 @@ -import React, { useCallback } from 'react'; +import React, { MouseEvent, useCallback } from 'react'; import { useNetwork, useSwitchNetwork } from 'wagmi'; import { useTranslation } from 'react-i18next'; import { LoadingButton, type LoadingButtonProps } from '@mui/lab'; @@ -7,12 +7,7 @@ import { Button } from '@mui/material'; import { useWeb3 } from 'hooks/useWeb3'; import { useModal } from 'contexts/ModalContext'; -interface MainActionButtonProps extends LoadingButtonProps { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - onClick?: (event?: any) => void; -} - -function MainActionButton({ onClick, ...props }: MainActionButtonProps) { +function MainActionButton({ onClick, ...props }: LoadingButtonProps) { const { t } = useTranslation(); const { isConnected, chain: displayNetwork, connect, impersonateActive, exitImpersonate } = useWeb3(); const { chain } = useNetwork(); @@ -24,8 +19,8 @@ function MainActionButton({ onClick, ...props }: MainActionButtonProps) { close(); }, [close, exitImpersonate]); - const handleSwitchNetworkAndExecuteMainAction = useCallback( - async (event?: React.MouseEvent) => { + const handleClick = useCallback( + async (event: MouseEvent) => { if (chain && chain.id !== displayNetwork.id && switchNetworkAsync) { try { const result = await switchNetworkAsync(displayNetwork.id); @@ -59,7 +54,7 @@ function MainActionButton({ onClick, ...props }: MainActionButtonProps) { ); } - return ; + return ; } export default React.memo(MainActionButton); diff --git a/components/dashboard/DashboardContent/FloatingPoolDashboard/FloatingPoolDashboardTable/SwitchCollateral/index.tsx b/components/dashboard/DashboardContent/FloatingPoolDashboard/FloatingPoolDashboardTable/SwitchCollateral/index.tsx index 657b8ae01..5b667a0c1 100644 --- a/components/dashboard/DashboardContent/FloatingPoolDashboard/FloatingPoolDashboardTable/SwitchCollateral/index.tsx +++ b/components/dashboard/DashboardContent/FloatingPoolDashboard/FloatingPoolDashboardTable/SwitchCollateral/index.tsx @@ -92,19 +92,18 @@ function SwitchCollateral({ symbol }: Props) { } }, [marketAccount, auditor, opts, checked, symbol, refreshAccountData]); - const siwtchNetworkAndToggle = useCallback(async () => { - if (chain && chain.id !== displayNetwork.id && switchNetworkAsync) { - try { - const result = await switchNetworkAsync(displayNetwork.id); - - if (result.id === displayNetwork.id) { - onToggle(); - } - } catch (error) { - return; + const switchNetworkAndToggle = useCallback(async () => { + if (!(chain && chain.id !== displayNetwork.id && switchNetworkAsync)) { + return onToggle(); + } + try { + const result = await switchNetworkAsync(displayNetwork.id); + + if (result.id === displayNetwork.id) { + onToggle(); } - } else { - onToggle(); + } catch (error) { + return; } }, [chain, displayNetwork.id, onToggle, switchNetworkAsync]); @@ -140,7 +139,7 @@ function SwitchCollateral({ symbol }: Props) {