From 294442e0f4db1b118fff6618e1f886ecaa79d0ce Mon Sep 17 00:00:00 2001 From: Milan Date: Mon, 20 Jul 2020 18:46:49 +0200 Subject: [PATCH] feat: fixed properly counting of min/max --- .../EnterAmount/Checkout/validation.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/blockchain-wallet-v4-frontend/src/modals/SimpleBuy/EnterAmount/Checkout/validation.tsx b/packages/blockchain-wallet-v4-frontend/src/modals/SimpleBuy/EnterAmount/Checkout/validation.tsx index 65893039839..3e1eb56fd0a 100644 --- a/packages/blockchain-wallet-v4-frontend/src/modals/SimpleBuy/EnterAmount/Checkout/validation.tsx +++ b/packages/blockchain-wallet-v4-frontend/src/modals/SimpleBuy/EnterAmount/Checkout/validation.tsx @@ -1,4 +1,5 @@ import { convertBaseToStandard } from 'data/components/exchange/services' +import { Props } from './template.success' import { SBCheckoutFormValuesType } from 'data/types' import { SBPairType, SBPaymentMethodType } from 'core/types' import BigNumber from 'bignumber.js' @@ -18,6 +19,9 @@ export const getMaxMin = ( const max = BigNumber.minimum(method.limits.max, pair.buyMax).toString() + // eslint-disable-next-line + console.log('max', max) + return convertBaseToStandard('FIAT', max) case 'min': const defaultMin = convertBaseToStandard('FIAT', 0) @@ -34,11 +38,13 @@ export const getMaxMin = ( export const maximumAmount = ( value: string, allValues: SBCheckoutFormValuesType, - pair: SBPairType, - method?: SBPaymentMethodType + restProps: Props ) => { if (!value) return true + + const { pair, method } = restProps if (!method) return true + return Number(value) > Number(getMaxMin(pair, 'max', allValues)) ? 'ABOVE_MAX' : false @@ -47,11 +53,13 @@ export const maximumAmount = ( export const minimumAmount = ( value: string, allValues: SBCheckoutFormValuesType, - pair: SBPairType, - method?: SBPaymentMethodType + restProps: Props ) => { if (!value) return true + + const { pair, method } = restProps if (!method) return true + return Number(value) < Number(getMaxMin(pair, 'min', allValues)) ? 'BELOW_MIN' : false