Skip to content

Commit

Permalink
fix: amount empty issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuzhy-Deriv committed Aug 8, 2024
1 parent a97a7cf commit f03e2bf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
35 changes: 18 additions & 17 deletions src/javascript/app/common/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,24 @@ const setMinMaxTimeObj = (options) => {
};

const paramsMap = {
'date_start' : PARAM_NAMES.DATE_START,
'time_start' : PARAM_NAMES.TIME_START,
'expiry_type' : PARAM_NAMES.EXPIRY_TYPE,
'duration_amount': PARAM_NAMES.DURATION_AMOUNT,
'duration_units' : PARAM_NAMES.DURATION_UNITS,
'expiry_date' : PARAM_NAMES.EXPIRY_DATE,
'expiry_time' : PARAM_NAMES.EXPIRY_TIME,
'barrier' : PARAM_NAMES.BARRIER,
'barrier_high' : PARAM_NAMES.BARRIER_HIGH,
'barrier_low' : PARAM_NAMES.BARRIER_LOW,
'prediction' : PARAM_NAMES.PREDICTION,
'selected_tick' : PARAM_NAMES.SELECTED_TICK,
'amount_type' : PARAM_NAMES.AMOUNT_TYPE,
'amount' : PARAM_NAMES.AMOUNT,
'currency' : PARAM_NAMES.CURRENCY,
'multiplier' : PARAM_NAMES.MULTIPLIER,
'callputequal' : PARAM_NAMES.IS_EQUAL,
'date_start' : PARAM_NAMES.DATE_START,
'time_start' : PARAM_NAMES.TIME_START,
'expiry_type' : PARAM_NAMES.EXPIRY_TYPE,
'duration_amount' : PARAM_NAMES.DURATION_AMOUNT,
'duration_units' : PARAM_NAMES.DURATION_UNITS,
'expiry_date' : PARAM_NAMES.EXPIRY_DATE,
'expiry_time' : PARAM_NAMES.EXPIRY_TIME,
'barrier' : PARAM_NAMES.BARRIER,
'barrier_high' : PARAM_NAMES.BARRIER_HIGH,
'barrier_low' : PARAM_NAMES.BARRIER_LOW,
'prediction' : PARAM_NAMES.PREDICTION,
'selected_tick' : PARAM_NAMES.SELECTED_TICK,
'amount_type' : PARAM_NAMES.AMOUNT_TYPE,
'amount' : PARAM_NAMES.AMOUNT,
'currency' : PARAM_NAMES.CURRENCY,
'multiplier_currency': PARAM_NAMES.CURRENCY,
'multiplier' : PARAM_NAMES.MULTIPLIER,
'callputequal' : PARAM_NAMES.IS_EQUAL,
};

const setDefaultParams = (elementId, value) => {
Expand Down
9 changes: 8 additions & 1 deletion src/javascript/app/pages/form/form-component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,28 @@ import {
useSessionChange,
useTradeChange,
eventDispatcher,
useMarketChange,
useContractChange,
} from '../../hooks/events.js';
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';

export const FormComponent = () => {
const [tradeData, setTradeData] = useState({});

const hasTradeChange = useTradeChange();
const hasMarketChange = useMarketChange();
const hasContractChange = useContractChange();
const hasSessionChange = useSessionChange();

useEffect(() => {
setTradeData((oldData) => ({
...oldData,
...dataManager.getAllTrades(),
}));
}, [hasTradeChange, hasSessionChange]);
}, [hasMarketChange, hasContractChange, hasTradeChange, hasSessionChange]);

const formName = Defaults.get(PARAM_NAMES.FORM_NAME);
const expiryType = Defaults.get(PARAM_NAMES.EXPIRY_TYPE);
Expand Down Expand Up @@ -122,6 +127,7 @@ export const FormComponent = () => {

const handleAmountChange = (e, id) => {
updateFormField(id, e.target.value, 'input');
setDefaultParams(id, e.target.value);
};

const findTextByValue = (arr, value) => arr.find(item => item.value === value)?.text || null;
Expand Down Expand Up @@ -215,6 +221,7 @@ export const FormComponent = () => {
e.target.value,
'input'
);
setDefaultParams('duration_amount', e.target.value);
}}
/>
</div>
Expand Down

0 comments on commit f03e2bf

Please sign in to comment.