From e11d3c2ac5baac3a7ccbc83a48cf567ba2d2b391 Mon Sep 17 00:00:00 2001
From: Nuzhy-Deriv <125249108+Nuzhy-Deriv@users.noreply.github.com>
Date: Mon, 12 Aug 2024 19:33:18 +0800
Subject: [PATCH 1/2] Nuzhy/_/translate currency group (#792)
* fix: translate currency group
* fix: currency group translated
---
src/javascript/app/pages/form/currency-dropdown.jsx | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/javascript/app/pages/form/currency-dropdown.jsx b/src/javascript/app/pages/form/currency-dropdown.jsx
index 4319d0b57a1..7ee4d845336 100644
--- a/src/javascript/app/pages/form/currency-dropdown.jsx
+++ b/src/javascript/app/pages/form/currency-dropdown.jsx
@@ -1,15 +1,21 @@
import React from 'react';
import { CustomDropdown, DropdownItem, DropdownTitle, useDropdown } from '@deriv-com/quill-ui';
import { setDefaultParams } from '../../common/helpers';
+import { localize } from '../../../_common/localize';
const CurrencyContent = ({ currency_list, currency, onUpdate, elementId }) => {
const { close } = useDropdown();
+ const getCurrencyGroupMap = {
+ fiat : localize('Fiat'),
+ crypto: localize('Crypto'),
+ };
+
return (
{Object.keys(currency_list).map((key) => (
-
+
{currency_list[key].map((item) => (
Date: Mon, 12 Aug 2024 19:45:41 +0800
Subject: [PATCH 2/2] fix: crypto amount issue (#795)
---
src/javascript/app/common/helpers.js | 8 +++++++-
src/javascript/app/pages/form/form-component.jsx | 8 ++++++--
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/javascript/app/common/helpers.js b/src/javascript/app/common/helpers.js
index b9d5ad48457..eed46e0fb80 100644
--- a/src/javascript/app/common/helpers.js
+++ b/src/javascript/app/common/helpers.js
@@ -7,6 +7,7 @@ import { getLocalTime } from '../base/clock';
import common_independent from '../pages/trade/common_independent';
import Defaults, { PARAM_NAMES } from '../pages/trade/defaults';
import { triggerSessionChange } from '../hooks/events';
+import { isCryptocurrency } from '../../_common/base/currency_base';
const parseData = (raw_data) => !raw_data ? '' : parse(raw_data);
@@ -130,7 +131,12 @@ const paramsMap = {
const setDefaultParams = (elementId, value) => {
if (paramsMap[elementId]) {
- Defaults.set(paramsMap[elementId], value);
+ const currency = Defaults.get(PARAM_NAMES.CURRENCY);
+ if (elementId === 'amount' && isCryptocurrency(currency)) {
+ Defaults.set('amount_crypto', value);
+ } else {
+ Defaults.set(paramsMap[elementId], value);
+ }
triggerSessionChange();
}
};
diff --git a/src/javascript/app/pages/form/form-component.jsx b/src/javascript/app/pages/form/form-component.jsx
index 229196b3285..bcdf1cfe763 100644
--- a/src/javascript/app/pages/form/form-component.jsx
+++ b/src/javascript/app/pages/form/form-component.jsx
@@ -25,6 +25,7 @@ import common_functions from '../../../_common/common_functions.js';
import { localize } from '../../../_common/localize.js';
import dataManager from '../../common/data_manager.js';
import { setDefaultParams } from '../../common/helpers.js';
+import { isCryptocurrency } from '../../../_common/base/currency_base.js';
export const FormComponent = () => {
const [tradeData, setTradeData] = useState({});
@@ -51,6 +52,7 @@ export const FormComponent = () => {
const expiry_time = Defaults.get(PARAM_NAMES.EXPIRY_TIME);
const amount_type = Defaults.get(PARAM_NAMES.AMOUNT_TYPE);
const amount = Defaults.get(PARAM_NAMES.AMOUNT);
+ const amount_crypto = Defaults.get('amount_crypto');
const currency = Defaults.get(PARAM_NAMES.CURRENCY);
const is_equal = Defaults.get(PARAM_NAMES.IS_EQUAL);
const prediction = Defaults.get(PARAM_NAMES.PREDICTION);
@@ -163,6 +165,8 @@ export const FormComponent = () => {
return moment(endtime_data.options[0].value).format('ddd - DD MMM, YYYY');
};
+ const getAmount = () => isCryptocurrency(currency) ? amount_crypto : amount;
+
return (
@@ -329,7 +333,7 @@ export const FormComponent = () => {
<>
handleAmountChange(e, 'amount')}
@@ -350,7 +354,7 @@ export const FormComponent = () => {
type='number'
allowDecimals
onChange={(e) => handleAmountChange(e, 'amount')}
- value={amount}
+ value={getAmount()}
addonLabel={currency}
addOnPosition='right'
/>