From e73f233c77e7e88fd77b03455684e32279c59323 Mon Sep 17 00:00:00 2001 From: Doan Sy Hung Date: Thu, 6 Jul 2023 18:00:33 +0700 Subject: [PATCH] update pending texts in modal --- .../ElasticPools/SinglePosition/CollectFeesPanel.tsx | 9 +++++---- src/pages/MyEarnings/TransactionConfirmationModal.tsx | 3 ++- src/pages/MyEarnings/constants.ts | 5 +++++ src/pages/MyEarnings/hooks.ts | 5 +++-- src/state/myEarnings/actions.ts | 2 +- src/state/myEarnings/reducer.ts | 10 +++++++++- 6 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/pages/MyEarnings/ElasticPools/SinglePosition/CollectFeesPanel.tsx b/src/pages/MyEarnings/ElasticPools/SinglePosition/CollectFeesPanel.tsx index 719218b286..feaf451b42 100644 --- a/src/pages/MyEarnings/ElasticPools/SinglePosition/CollectFeesPanel.tsx +++ b/src/pages/MyEarnings/ElasticPools/SinglePosition/CollectFeesPanel.tsx @@ -18,6 +18,7 @@ import useTheme from 'hooks/useTheme' import useTransactionDeadline from 'hooks/useTransactionDeadline' import { useChangeNetwork } from 'hooks/web3/useChangeNetwork' import HoverDropdown from 'pages/MyEarnings/HoverDropdown' +import { MODAL_PENDING_TEXTS } from 'pages/MyEarnings/constants' import { setAttemptingTxn, setShowPendingModal, setTxError, setTxnHash } from 'state/myEarnings/actions' import { useTransactionAdder } from 'state/transactions/hooks' import { TRANSACTION_TYPE } from 'state/transactions/type' @@ -115,7 +116,7 @@ const CollectFeesPanel: React.FC = ({ }) }) .catch((error: any) => { - dispatch(setShowPendingModal(true)) + dispatch(setShowPendingModal(MODAL_PENDING_TEXTS.COLLECT_FEES)) dispatch(setAttemptingTxn(false)) dispatch(setTxError(error?.message || JSON.stringify(error))) console.error(error) @@ -158,14 +159,14 @@ const CollectFeesPanel: React.FC = ({ dispatch(setAttemptingTxn(false)) dispatch(setTxnHash(txResponse.hash)) } catch (e) { - dispatch(setShowPendingModal(true)) + dispatch(setShowPendingModal(MODAL_PENDING_TEXTS.COLLECT_FEES)) dispatch(setAttemptingTxn(false)) dispatch(setTxError(e?.message || JSON.stringify(e))) } } const collectFeesForElasticPosition = () => { - dispatch(setShowPendingModal(true)) + dispatch(setShowPendingModal(MODAL_PENDING_TEXTS.COLLECT_FEES)) dispatch(setAttemptingTxn(true)) if (!feeValue0 || !feeValue1 || !positionManager || !account || !library || !deadline) { @@ -198,7 +199,7 @@ const CollectFeesPanel: React.FC = ({ } const collectFeesForElasticLegacyPosition = () => { - dispatch(setShowPendingModal(true)) + dispatch(setShowPendingModal(MODAL_PENDING_TEXTS.COLLECT_FEES)) dispatch(setAttemptingTxn(true)) if (!feeValue0 || !feeValue1 || !positionManager || !account || !library || !deadline) { diff --git a/src/pages/MyEarnings/TransactionConfirmationModal.tsx b/src/pages/MyEarnings/TransactionConfirmationModal.tsx index 0b2b1863f8..e52603f112 100644 --- a/src/pages/MyEarnings/TransactionConfirmationModal.tsx +++ b/src/pages/MyEarnings/TransactionConfirmationModal.tsx @@ -13,6 +13,7 @@ const TransactionConfirmationModal = () => { const txnHash = useAppSelector(state => state.myEarnings.txnHash) const attemptingTxn = useAppSelector(state => state.myEarnings.attemptingTxn) const collectFeeError = useAppSelector(state => state.myEarnings.txError) + const pendingText = useAppSelector(state => state.myEarnings.pendingText) const handleDismiss = useCallback(() => { dispatch(setShowPendingModal(false)) @@ -31,7 +32,7 @@ const TransactionConfirmationModal = () => { onDismiss={handleDismiss} hash={txnHash} attemptingTxn={attemptingTxn} - pendingText={`Collecting fee rewards`} + pendingText={pendingText} content={() => ( {collectFeeError ? : null} diff --git a/src/pages/MyEarnings/constants.ts b/src/pages/MyEarnings/constants.ts index 25d3248367..68cad843cf 100644 --- a/src/pages/MyEarnings/constants.ts +++ b/src/pages/MyEarnings/constants.ts @@ -3,3 +3,8 @@ export const WIDTHS: Record { - dispatch(setShowPendingModal(true)) + dispatch(setShowPendingModal(MODAL_PENDING_TEXTS.REMOVE_LIQUIDITY)) dispatch(setAttemptingTxn(true)) if (!deadline || !account || !library) { @@ -354,7 +355,7 @@ export function useRemoveLiquidityFromLegacyPosition( }) }) .catch((error: any) => { - dispatch(setShowPendingModal(true)) + dispatch(setShowPendingModal(MODAL_PENDING_TEXTS.REMOVE_LIQUIDITY)) dispatch(setAttemptingTxn(false)) if (error?.code !== 'ACTION_REJECTED') { diff --git a/src/state/myEarnings/actions.ts b/src/state/myEarnings/actions.ts index e7c4ff2770..eba3778a47 100644 --- a/src/state/myEarnings/actions.ts +++ b/src/state/myEarnings/actions.ts @@ -13,4 +13,4 @@ export const setActiveTab = createAction('myEarnings/setActiveTab') export const setTxError = createAction('myEarnings/setTxError') export const setAttemptingTxn = createAction('myEarnings/setAttemptingTxn') export const setTxnHash = createAction('myEarnings/setTxnHash') -export const setShowPendingModal = createAction('myEarnings/setShowPendingModal') +export const setShowPendingModal = createAction('myEarnings/setShowPendingModal') diff --git a/src/state/myEarnings/reducer.ts b/src/state/myEarnings/reducer.ts index 752bca2893..8e0bccffb2 100644 --- a/src/state/myEarnings/reducer.ts +++ b/src/state/myEarnings/reducer.ts @@ -28,6 +28,7 @@ export interface MyEarningsState { readonly attemptingTxn: boolean readonly showPendingModal: boolean readonly txError: string + readonly pendingText: string } const initialState: MyEarningsState = { @@ -41,6 +42,7 @@ const initialState: MyEarningsState = { attemptingTxn: false, showPendingModal: false, txError: '', + pendingText: '', } export default createReducer(initialState, builder => @@ -74,6 +76,12 @@ export default createReducer(initialState, builder => state.txnHash = action.payload }) .addCase(setShowPendingModal, (state, action) => { - state.showPendingModal = action.payload + if (action.payload) { + state.showPendingModal = true + state.pendingText = action.payload + } else { + state.showPendingModal = false + state.pendingText = '' + } }), )