From 657abc83d9fc17b096021d098ee9bb8502f59960 Mon Sep 17 00:00:00 2001 From: Nathan Seva Date: Tue, 23 Jul 2024 10:05:12 -0500 Subject: [PATCH] clean code while debugging (#761) --- src/i18n/en_US.json | 1 - .../LoadingLayout/PendingOperationLayout.tsx | 21 ++++++++++--------- .../RedeemLayout/ClaimRedeem.tsx | 9 ++------ src/utils/lambdaApi.ts | 4 +--- 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/i18n/en_US.json b/src/i18n/en_US.json index 98b614eb..627ebbcb 100644 --- a/src/i18n/en_US.json +++ b/src/i18n/en_US.json @@ -274,7 +274,6 @@ "claim": { "error": { "rejected": "Claim rejected by user, try again", - "timeout": "Claim timeout out.", "unknown": "Unknown error, Try again." } }, diff --git a/src/pages/IndexPage/Layouts/LoadingLayout/PendingOperationLayout.tsx b/src/pages/IndexPage/Layouts/LoadingLayout/PendingOperationLayout.tsx index a14a08c9..88441a17 100644 --- a/src/pages/IndexPage/Layouts/LoadingLayout/PendingOperationLayout.tsx +++ b/src/pages/IndexPage/Layouts/LoadingLayout/PendingOperationLayout.tsx @@ -17,21 +17,22 @@ export function PendingOperationLayout() { const { box } = useGlobalStatusesStore(); - const IS_BOX_SUCCESS = box === Status.Success; - const IS_BOX_WARNING = box === Status.Warning; - const IS_BOX_ERROR = box === Status.Error; + const isBoxSuccess = box === Status.Success; + const isBoxWarning = box === Status.Warning; + const isBoxError = box === Status.Error; - const displaySubtitle = !IS_BOX_SUCCESS && !IS_BOX_WARNING && !IS_BOX_ERROR; + const displaySubtitle = !isBoxSuccess && !isBoxWarning && !isBoxError; - const isNotProcessing = IS_BOX_SUCCESS || IS_BOX_WARNING || IS_BOX_ERROR; + const isNotProcessing = isBoxSuccess || isBoxWarning || isBoxError; function getLoadingBoxHeader() { - if (IS_BOX_SUCCESS) return Intl.t('index.loading-box.success'); - else if (IS_BOX_ERROR) { + if (isBoxSuccess) return Intl.t('index.loading-box.success'); + if (isBoxError) { return massaToEvm ? Intl.t('index.loading-box.title-redeem-error') : Intl.t('index.loading-box.title-bridge-error'); - } else if (IS_BOX_WARNING) { + } + if (isBoxWarning) { return massaToEvm ? ( <> {Intl.t('index.loading-box.title-redeem-warning-1')} @@ -54,9 +55,9 @@ export function PendingOperationLayout() { function getLoadingBoxContent() { switch (true) { - case IS_BOX_SUCCESS: + case isBoxSuccess: return ; - case IS_BOX_WARNING: + case isBoxWarning: return ; case massaToEvm: return ; diff --git a/src/pages/IndexPage/Layouts/LoadingLayout/RedeemLayout/ClaimRedeem.tsx b/src/pages/IndexPage/Layouts/LoadingLayout/RedeemLayout/ClaimRedeem.tsx index c7d0db07..fca9c87f 100644 --- a/src/pages/IndexPage/Layouts/LoadingLayout/RedeemLayout/ClaimRedeem.tsx +++ b/src/pages/IndexPage/Layouts/LoadingLayout/RedeemLayout/ClaimRedeem.tsx @@ -48,11 +48,6 @@ export function ClaimRedeem() { [burnTxId, updateBurnRedeemOperationById], ); - const setLoadingToError = useCallback(() => { - setClaim(Status.Error); - setBox(Status.Error); - }, [setClaim, setBox]); - // Updates current redeem operation state based on claim status useEffect(() => { if (hash) setClaimTxId(hash); @@ -76,7 +71,8 @@ export function ClaimRedeem() { claimState: ClaimState.REJECTED, }); } else { - setLoadingToError(); + setClaim(Status.Error); + setBox(Status.Error); updateCurrentRedeemOperation({ claimState: ClaimState.ERROR, }); @@ -91,7 +87,6 @@ export function ClaimRedeem() { refreshBalances, setClaim, updateCurrentRedeemOperation, - setLoadingToError, setClaimTxId, ]); diff --git a/src/utils/lambdaApi.ts b/src/utils/lambdaApi.ts index f0d86d7f..ecb0f18a 100644 --- a/src/utils/lambdaApi.ts +++ b/src/utils/lambdaApi.ts @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'; import { useAccount } from 'wagmi'; import { ClaimState } from './const'; import { config } from '../const'; -import { useBridgeModeStore, useGlobalStatusesStore } from '../store/store'; +import { useBridgeModeStore } from '../store/store'; import { useResource } from '@/custom/api/useResource'; import { BurnRedeemOperation, useOperationStore } from '@/store/operationStore'; @@ -143,7 +143,6 @@ function getClaimState( export function useFetchSignatures() { const { burnTxId, getCurrentRedeemOperation, updateBurnRedeemOperationById } = useOperationStore(); - const { setBox } = useGlobalStatusesStore(); const { currentMode } = useBridgeModeStore(); const { address: evmAddress } = useAccount(); @@ -181,7 +180,6 @@ export function useFetchSignatures() { }, [ burnTxId, burnOperations, - setBox, getCurrentRedeemOperation, updateBurnRedeemOperationById, ]);