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/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) => ( { 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' />