From 4af7e75d92d809629aa7ff51a8b657e3b55415cc Mon Sep 17 00:00:00 2001 From: sebipap Date: Fri, 10 May 2024 17:40:40 -0300 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20fix=20types=20&=20typos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/common/MainActionButton/index.tsx | 15 ++++------- .../SwitchCollateral/index.tsx | 25 +++++++++---------- 2 files changed, 17 insertions(+), 23 deletions(-) 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) {