From 3e132effaae375fcd91f7f73a063abc6cf49315c Mon Sep 17 00:00:00 2001 From: George Usynin <103181646+heorhi-deriv@users.noreply.github.com> Date: Wed, 21 Feb 2024 17:14:35 +0300 Subject: [PATCH] fix(cashier): :ambulance: crypto amounts not properly converted (#13735) --- .../crypto-fiat-converter/crypto-fiat-converter.tsx | 4 ++-- packages/cashier/src/stores/crypto-fiat-converter-store.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/cashier/src/components/crypto-fiat-converter/crypto-fiat-converter.tsx b/packages/cashier/src/components/crypto-fiat-converter/crypto-fiat-converter.tsx index c3bf68902e3a..0204b043bd7d 100644 --- a/packages/cashier/src/components/crypto-fiat-converter/crypto-fiat-converter.tsx +++ b/packages/cashier/src/components/crypto-fiat-converter/crypto-fiat-converter.tsx @@ -28,8 +28,8 @@ type TCryptoFiatConverterProps = { ) => void; onChangeConverterToAmount: ( event: TReactChangeEvent, - from_currency: string, to_currency: string, + from_currency: string, converted_amount?: number ) => void; resetConverter: VoidFunction; @@ -130,7 +130,7 @@ const CryptoFiatConverter = observer( onChange={(e: TReactChangeEvent) => { const rate = exchange_rates?.[to_currency]?.[from_currency] ?? 0; const converted_amount = Number(e.target.value) * rate; - onChangeConverterToAmount(e, from_currency, to_currency, converted_amount); + onChangeConverterToAmount(e, to_currency, from_currency, converted_amount); handleChange(e); }} type='text' diff --git a/packages/cashier/src/stores/crypto-fiat-converter-store.ts b/packages/cashier/src/stores/crypto-fiat-converter-store.ts index c06ecdc3b7c6..fc8fa8deadc7 100644 --- a/packages/cashier/src/stores/crypto-fiat-converter-store.ts +++ b/packages/cashier/src/stores/crypto-fiat-converter-store.ts @@ -113,8 +113,8 @@ export default class CryptoFiatConverterStore { async onChangeConverterToAmount( { target }: { target: { value: string } }, - from_currency: string, to_currency: string, + from_currency: string, converted_amount?: number ): Promise { const { account_transfer, general_store } = this.root_store.modules.cashier; @@ -129,7 +129,7 @@ export default class CryptoFiatConverterStore { this.setIsTimerVisible(false); account_transfer.setAccountTransferAmount(''); } else { - const decimals = getDecimalPlaces(to_currency); + const decimals = getDecimalPlaces(from_currency); const amount = converted_amount?.toFixed(decimals) || '1'; if (+amount || this.converter_to_amount) { this.setConverterFromAmount(amount);