From 2dd12cc08664ad4a8d785a124cded95f126f5ca3 Mon Sep 17 00:00:00 2001 From: Farrah Mae Ochoa Date: Thu, 7 Jul 2022 16:48:42 +0400 Subject: [PATCH 1/2] fixed input amount validation --- .../p2p/src/components/buy-sell/buy-sell-form.jsx | 2 +- packages/p2p/src/stores/buy-sell-store.js | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/p2p/src/components/buy-sell/buy-sell-form.jsx b/packages/p2p/src/components/buy-sell/buy-sell-form.jsx index bdd3faef538d..ab9bc96f1193 100644 --- a/packages/p2p/src/components/buy-sell/buy-sell-form.jsx +++ b/packages/p2p/src/components/buy-sell/buy-sell-form.jsx @@ -129,7 +129,7 @@ const BuySellForm = props => { validate={buy_sell_store.validatePopup} validateOnMount={!should_disable_field} initialValues={{ - amount: min_order_amount_limit, + amount: input_amount, contact_info: buy_sell_store.contact_info, payment_info: buy_sell_store.payment_info, rate: rate_type === ad_type.FLOAT ? effective_rate : null, diff --git a/packages/p2p/src/stores/buy-sell-store.js b/packages/p2p/src/stores/buy-sell-store.js index 5b5166ccc0c1..779564759a36 100644 --- a/packages/p2p/src/stores/buy-sell-store.js +++ b/packages/p2p/src/stores/buy-sell-store.js @@ -525,9 +525,9 @@ export default class BuySellStore extends BaseStore { const validations = { amount: [ v => !!v, - v => (this.root_store.buy_sell_store.is_buy_advert ? true : v <= this.root_store.general_store.balance), v => v >= this.advert.min_order_amount_limit, v => v <= this.advert.max_order_amount_limit, + v => (this.root_store.buy_sell_store.is_buy_advert ? true : v <= this.root_store.general_store.balance), v => countDecimalPlaces(v) <= getDecimalPlaces(this.account_currency), ], }; @@ -544,10 +544,6 @@ export default class BuySellStore extends BaseStore { const common_messages = [ localize('Enter a valid amount'), - localize('Maximum is {{value}} {{currency}}', { - currency: this.account_currency, - value: formatMoney(this.account_currency, this.root_store.general_store.balance, true), - }), localize('Minimum is {{value}} {{currency}}', { currency: this.account_currency, value: display_min_amount, @@ -556,6 +552,11 @@ export default class BuySellStore extends BaseStore { currency: this.account_currency, value: display_max_amount, }), + + localize('Maximum is {{value}} {{currency}}', { + currency: this.account_currency, + value: formatMoney(this.account_currency, this.root_store.general_store.balance, true), + }), localize('Enter a valid amount'), ]; From faf23dc6d3cb2c5fcec68c88aa7d1ccab4dbcabd Mon Sep 17 00:00:00 2001 From: Farrah Mae Ochoa Date: Thu, 7 Jul 2022 16:50:38 +0400 Subject: [PATCH 2/2] refactor code --- packages/p2p/src/stores/buy-sell-store.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/p2p/src/stores/buy-sell-store.js b/packages/p2p/src/stores/buy-sell-store.js index 779564759a36..f571152241eb 100644 --- a/packages/p2p/src/stores/buy-sell-store.js +++ b/packages/p2p/src/stores/buy-sell-store.js @@ -552,7 +552,6 @@ export default class BuySellStore extends BaseStore { currency: this.account_currency, value: display_max_amount, }), - localize('Maximum is {{value}} {{currency}}', { currency: this.account_currency, value: formatMoney(this.account_currency, this.root_store.general_store.balance, true),