From 3db997459b4a7ed12361cc78f66c35adb90bc206 Mon Sep 17 00:00:00 2001 From: Tom Robiquet Date: Wed, 6 Dec 2023 14:20:26 +0200 Subject: [PATCH 1/2] Handle 0 balances better in trade form --- components/trade-form/BuyForm.tsx | 12 +++++++++--- components/trade-form/SellForm.tsx | 8 +++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/components/trade-form/BuyForm.tsx b/components/trade-form/BuyForm.tsx index 83b3a76b7..15697d460 100644 --- a/components/trade-form/BuyForm.tsx +++ b/components/trade-form/BuyForm.tsx @@ -182,7 +182,13 @@ const BuyForm = ({ const subscription = watch((value, { name, type }) => { const changedByUser = type != null; - if (!changedByUser || !maxSpendableBalance || !maxAmountIn) return; + if ( + !changedByUser || + !maxSpendableBalance || + maxSpendableBalance.eq(0) || + !maxAmountIn + ) + return; if (name === "percentage") { const max = maxSpendableBalance.greaterThan(maxAmountIn) @@ -255,9 +261,9 @@ const BuyForm = ({ }, validate: (value) => { if (value > (maxSpendableBalance?.div(ZTG).toNumber() ?? 0)) { - return `Insufficient balance. Current balance: ${maxSpendableBalance + return `Insufficient balance (${maxSpendableBalance ?.div(ZTG) - .toFixed(3)}`; + .toFixed(3)}${baseSymbol})`; } else if (value <= 0) { return "Value cannot be zero or less"; } else if (maxAmountIn?.div(ZTG)?.lessThanOrEqualTo(value)) { diff --git a/components/trade-form/SellForm.tsx b/components/trade-form/SellForm.tsx index a0c860ed9..9c9dd0a28 100644 --- a/components/trade-form/SellForm.tsx +++ b/components/trade-form/SellForm.tsx @@ -166,7 +166,13 @@ const SellForm = ({ const subscription = watch((value, { name, type }) => { const changedByUser = type != null; - if (!changedByUser || !selectedAssetBalance || !maxAmountIn) return; + if ( + !changedByUser || + !selectedAssetBalance || + selectedAssetBalance.eq(0) || + !maxAmountIn + ) + return; if (name === "percentage") { const max = selectedAssetBalance.greaterThan(maxAmountIn) From d6141b1b5b76c7ea5df48b5032434c26e33703d1 Mon Sep 17 00:00:00 2001 From: Tom Robiquet Date: Wed, 6 Dec 2023 14:22:31 +0200 Subject: [PATCH 2/2] Banner copy change --- components/front-page/HeroBanner.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/front-page/HeroBanner.tsx b/components/front-page/HeroBanner.tsx index 9064f3d51..8fb1bc899 100644 --- a/components/front-page/HeroBanner.tsx +++ b/components/front-page/HeroBanner.tsx @@ -31,7 +31,7 @@ export const HeroBanner = ({ Welcome to the Future of Betting

- Zeitgeist is a new innovative platform for predicting future events + Zeitgeist is an innovative platform for predicting future events