From 1471d0fa21cfd44a9a787a92b2c0798c10e714f6 Mon Sep 17 00:00:00 2001 From: bonomat Date: Thu, 18 Nov 2021 15:05:39 +1100 Subject: [PATCH 1/3] Disable to go-long button if - balance < required margin - entered quantity > max_quantity or < min_quantity - entered quantity <= 0 --- taker-frontend/src/App.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/taker-frontend/src/App.tsx b/taker-frontend/src/App.tsx index 24ce792..fe643ad 100644 --- a/taker-frontend/src/App.tsx +++ b/taker-frontend/src/App.tsx @@ -130,6 +130,14 @@ export const App = () => { const format = (val: any) => `$` + val; const parse = (val: any) => val.replace(/^\$/, ""); + const balanceTooLow = walletInfo && walletInfo.balance < parse(margin); + const quantityTooHigh = order && order.max_quantity < parse(effectiveQuantity); + const quantityTooLow = order && order.min_quantity > parse(effectiveQuantity); + const quantityGreaterZero = parse(effectiveQuantity) > 0; + + const canSubmit = order != null && !isCreatingNewOrderRequest && walletInfo != null && !balanceTooLow + && !quantityTooHigh && !quantityTooLow && quantityGreaterZero; + return ( <>