From 2bb3dc9ade607d0a95f43adda2f3284e2b29fe6f Mon Sep 17 00:00:00 2001 From: Nuzhy-Deriv Date: Tue, 6 Aug 2024 19:48:40 +0800 Subject: [PATCH] fix: pr comments addressed --- src/javascript/app/common/data_manager.js | 23 ++++++++----------- .../app/pages/trade/not-available.jsx | 2 +- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/javascript/app/common/data_manager.js b/src/javascript/app/common/data_manager.js index e215a1d47d9..8c5a40e1585 100644 --- a/src/javascript/app/common/data_manager.js +++ b/src/javascript/app/common/data_manager.js @@ -6,6 +6,12 @@ import { triggerTradeChange, } from '../hooks/events'; +const changeTypeMap = { + trade : 'tradeChange', + purchase: 'purchaseChange', + contract: 'contractChange', +}; + class DataManager { constructor() { this.data = { @@ -15,12 +21,7 @@ class DataManager { }; } - set(data, data_type, optional) { - const changeTypeMap = { - trade : 'tradeChange', - purchase: 'purchaseChange', - contract: 'contractChange', - }; + set(data, data_type, optional_trigger) { if (typeof data === 'object') { const oldValues = {}; const newValues = {}; @@ -36,9 +37,9 @@ class DataManager { window.dispatchEvent(new CustomEvent(changeTypeMap[data_type], { detail: { oldValues, newValues }, })); - if (optional === 'barrier') { + if (optional_trigger === 'barrier') { triggerBarrierChange(); - } else if (optional === 'time') { + } else if (optional_trigger === 'time') { triggerTimeChange(); } else { switch (data_type) { @@ -73,11 +74,7 @@ class DataManager { clear(data_type) { const oldValues = { ...this.data[data_type] }; this.data[data_type] = {}; - const changeTypeMap = { - trade : 'tradeChange', - purchase: 'purchaseChange', - contract: 'contractChange', - }; + window.dispatchEvent(new CustomEvent(changeTypeMap[data_type], { detail: { oldValues, newValues: {} }, })); diff --git a/src/javascript/app/pages/trade/not-available.jsx b/src/javascript/app/pages/trade/not-available.jsx index cf0d399c98c..833cd7232ef 100644 --- a/src/javascript/app/pages/trade/not-available.jsx +++ b/src/javascript/app/pages/trade/not-available.jsx @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom'; import { Text, Button } from '@deriv-com/quill-ui'; import { getElementById } from '../../../_common/common_functions'; import { localize } from '../../../_common/localize.js'; -import dataManager from '../../common/contract_manager.js'; +import dataManager from '../../common/data_manager.js'; const NotAvailable = ({ title, body }) => (