From f9834006dcd93a48c1fcb5e0eb1a0826266f9677 Mon Sep 17 00:00:00 2001 From: hotequil Date: Wed, 18 Dec 2024 16:59:47 -0300 Subject: [PATCH] CU-86a5xqdaq-NEON3 - Swap Request - Show error toast when Pair is unavailable --- .../src/routes/pages/Swap/SwapPageContent.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/renderer/src/routes/pages/Swap/SwapPageContent.tsx b/src/renderer/src/routes/pages/Swap/SwapPageContent.tsx index 00754c8e..49ce6eba 100644 --- a/src/renderer/src/routes/pages/Swap/SwapPageContent.tsx +++ b/src/renderer/src/routes/pages/Swap/SwapPageContent.tsx @@ -26,6 +26,7 @@ import { TransactionFeeActionStep } from '@renderer/components/TransactionFeeAct import { SWAP_NETWORK_BY_BLOCKCHAIN_AND_NETWORK_ID } from '@renderer/constants/swap' import { AccountHelper } from '@renderer/helpers/AccountHelper' import { NumberHelper } from '@renderer/helpers/NumberHelper' +import { ToastHelper } from '@renderer/helpers/ToastHelper' import { UtilsHelper } from '@renderer/helpers/UtilsHelper' import { useAccountsSelector } from '@renderer/hooks/useAccountSelector' import { useActions } from '@renderer/hooks/useActions' @@ -168,11 +169,19 @@ export const SwapPageContent = ({ account }: TProps) => { setData({ selectAmountToUseMinMax: amountToUseMinMax }) }) + swapService.eventEmitter.on('error', error => { + ToastHelper.error({ message: error, duration: 6000 }) + }) + swapServiceRef.current = swapService swapService.init() } + const removeSwapServiceListeners = () => { + swapServiceRef.current?.eventEmitter.removeAllListeners() + } + const handleSelectTokenToUse = (token: SwapServiceToken) => { swapServiceRef.current.setTokenToUse(token) } @@ -278,10 +287,6 @@ export const SwapPageContent = ({ account }: TProps) => { } } - const removeSwapServiceListeners = () => { - swapServiceRef.current?.eventEmitter.removeAllListeners() - } - useEffect(() => { if (balanceQuery.isLoading) return