Skip to content

Commit a0829fb

Browse files
authored
fix: crypto amount issue (#795)
1 parent e11d3c2 commit a0829fb

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/javascript/app/common/helpers.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { getLocalTime } from '../base/clock';
77
import common_independent from '../pages/trade/common_independent';
88
import Defaults, { PARAM_NAMES } from '../pages/trade/defaults';
99
import { triggerSessionChange } from '../hooks/events';
10+
import { isCryptocurrency } from '../../_common/base/currency_base';
1011

1112
const parseData = (raw_data) => !raw_data ? '' : parse(raw_data);
1213

@@ -130,7 +131,12 @@ const paramsMap = {
130131

131132
const setDefaultParams = (elementId, value) => {
132133
if (paramsMap[elementId]) {
133-
Defaults.set(paramsMap[elementId], value);
134+
const currency = Defaults.get(PARAM_NAMES.CURRENCY);
135+
if (elementId === 'amount' && isCryptocurrency(currency)) {
136+
Defaults.set('amount_crypto', value);
137+
} else {
138+
Defaults.set(paramsMap[elementId], value);
139+
}
134140
triggerSessionChange();
135141
}
136142
};

src/javascript/app/pages/form/form-component.jsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import common_functions from '../../../_common/common_functions.js';
2525
import { localize } from '../../../_common/localize.js';
2626
import dataManager from '../../common/data_manager.js';
2727
import { setDefaultParams } from '../../common/helpers.js';
28+
import { isCryptocurrency } from '../../../_common/base/currency_base.js';
2829

2930
export const FormComponent = () => {
3031
const [tradeData, setTradeData] = useState({});
@@ -51,6 +52,7 @@ export const FormComponent = () => {
5152
const expiry_time = Defaults.get(PARAM_NAMES.EXPIRY_TIME);
5253
const amount_type = Defaults.get(PARAM_NAMES.AMOUNT_TYPE);
5354
const amount = Defaults.get(PARAM_NAMES.AMOUNT);
55+
const amount_crypto = Defaults.get('amount_crypto');
5456
const currency = Defaults.get(PARAM_NAMES.CURRENCY);
5557
const is_equal = Defaults.get(PARAM_NAMES.IS_EQUAL);
5658
const prediction = Defaults.get(PARAM_NAMES.PREDICTION);
@@ -163,6 +165,8 @@ export const FormComponent = () => {
163165
return moment(endtime_data.options[0].value).format('ddd - DD MMM, YYYY');
164166
};
165167

168+
const getAmount = () => isCryptocurrency(currency) ? amount_crypto : amount;
169+
166170
return (
167171
<BreakpointProvider>
168172
<div className='quill-form-container'>
@@ -329,7 +333,7 @@ export const FormComponent = () => {
329333
<>
330334
<div className='form_field field-pb'>
331335
<TextField
332-
value={amount}
336+
value={getAmount()}
333337
type='number'
334338
allowDecimals={true}
335339
onChange={(e) => handleAmountChange(e, 'amount')}
@@ -350,7 +354,7 @@ export const FormComponent = () => {
350354
type='number'
351355
allowDecimals
352356
onChange={(e) => handleAmountChange(e, 'amount')}
353-
value={amount}
357+
value={getAmount()}
354358
addonLabel={currency}
355359
addOnPosition='right'
356360
/>

0 commit comments

Comments
 (0)