Skip to content

Commit

Permalink
Merge branch 'master' into hot-fix-rise-fall-audit
Browse files Browse the repository at this point in the history
  • Loading branch information
prince-deriv authored Aug 12, 2024
2 parents e250079 + a0829fb commit d8b80d4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/javascript/app/common/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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();
}
};
Expand Down
8 changes: 7 additions & 1 deletion src/javascript/app/pages/form/currency-dropdown.jsx
Original file line number Diff line number Diff line change
@@ -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 (
<div className='custom-dropdown-wrapper'>
{Object.keys(currency_list).map((key) => (
<div key={key}>
<DropdownTitle label={key.toLocaleUpperCase()} />
<DropdownTitle label={getCurrencyGroupMap[key]} />
{currency_list[key].map((item) => (
<DropdownItem
key={item.value}
Expand Down
8 changes: 6 additions & 2 deletions src/javascript/app/pages/form/form-component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({});
Expand All @@ -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);
Expand Down Expand Up @@ -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 (
<BreakpointProvider>
<div className='quill-form-container'>
Expand Down Expand Up @@ -329,7 +333,7 @@ export const FormComponent = () => {
<>
<div className='form_field field-pb'>
<TextField
value={amount}
value={getAmount()}
type='number'
allowDecimals={true}
onChange={(e) => handleAmountChange(e, 'amount')}
Expand All @@ -350,7 +354,7 @@ export const FormComponent = () => {
type='number'
allowDecimals
onChange={(e) => handleAmountChange(e, 'amount')}
value={amount}
value={getAmount()}
addonLabel={currency}
addOnPosition='right'
/>
Expand Down

0 comments on commit d8b80d4

Please sign in to comment.