From c683eb89d0f51e0bf8e50d4ccd6e7c9f42c2bd8a Mon Sep 17 00:00:00 2001 From: Madalina Raicu Date: Mon, 13 Mar 2023 15:32:04 +0000 Subject: [PATCH] fix: deal ticket infinite render on set summary error on empty balance --- .../components/deal-ticket/deal-ticket.tsx | 32 +++++++------------ 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx index d5af42701..03c3fc259 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx @@ -116,16 +116,6 @@ export const DealTicket = ({ return; } - const hasNoBalance = - generalAccountBalance === '0' || generalAccountBalance === ''; - if (hasNoBalance) { - setError('summary', { - message: SummaryValidationType.NoCollateral, - type: SummaryValidationType.NoCollateral, - }); - return; - } - const marketTradingModeError = validateMarketTradingMode(marketTradingMode); if (marketTradingModeError !== true) { setError('summary', { @@ -362,16 +352,6 @@ const SummaryMessage = memo( ); } - if (errorMessage === SummaryValidationType.NoCollateral) { - return ( -
- -
- ); - } // If we have any other full error which prevents // submission render that first @@ -388,9 +368,19 @@ const SummaryMessage = memo( // If there is no blocking error but user doesn't have enough // balance render the margin warning, but still allow submission if (BigInt(balance) < BigInt(margin)) { + if (BigInt(balance) > BigInt(0)) { + return ( +
+ +
+ ); + } return (
- +
); }