From 21fd5b1631ceae2ca54df63ec8dc62579c788a97 Mon Sep 17 00:00:00 2001 From: Keith Date: Mon, 11 Nov 2019 09:35:07 +0800 Subject: [PATCH] feat(neuron-ui): show local error message ahead of remote error message --- packages/neuron-ui/src/components/Send/hooks.ts | 2 +- packages/neuron-ui/src/components/Send/index.tsx | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/neuron-ui/src/components/Send/hooks.ts b/packages/neuron-ui/src/components/Send/hooks.ts index e8b0cd3adc..03f99089ee 100644 --- a/packages/neuron-ui/src/components/Send/hooks.ts +++ b/packages/neuron-ui/src/components/Send/hooks.ts @@ -99,7 +99,7 @@ const useOnTransactionChange = ( }) } }, 300) - }, [walletID, items, price, dispatch, setTotalAmount]) + }, [walletID, items, price, dispatch, setTotalAmount, setErrorMessage]) } const useOnSubmit = (items: TransactionOutput[], dispatch: StateDispatch) => diff --git a/packages/neuron-ui/src/components/Send/index.tsx b/packages/neuron-ui/src/components/Send/index.tsx index b3ba259a8f..79447fbaf6 100644 --- a/packages/neuron-ui/src/components/Send/index.tsx +++ b/packages/neuron-ui/src/components/Send/index.tsx @@ -62,10 +62,9 @@ const Send = ({ const leftStackWidth = '70%' const labelWidth = '140px' - let errorMessageUnderTotal = errorMessage - if (!errorMessageUnderTotal && !verifyTotalAmount(totalAmount, fee, balance)) { - errorMessageUnderTotal = t(`messages.codes.${ErrorCode.AmountNotEnough}`) - } + const errorMessageUnderTotal = verifyTotalAmount(totalAmount, fee, balance) + ? errorMessage + : t(`messages.codes.${ErrorCode.AmountNotEnough}`) return (