Skip to content

Commit

Permalink
farrah/ fixed input amount validation on buy/sell form (#5928)
Browse files Browse the repository at this point in the history
* fixed input amount validation

* refactor code
  • Loading branch information
farrah-deriv committed Jul 7, 2022
1 parent fab89d2 commit 121ac70
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/p2p/src/components/buy-sell/buy-sell-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions packages/p2p/src/stores/buy-sell-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
],
};
Expand All @@ -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,
Expand All @@ -556,6 +552,10 @@ 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'),
];

Expand Down

0 comments on commit 121ac70

Please sign in to comment.