Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuzhy/trade parameters UI [Quill] #674

Merged
merged 21 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
fab9f4c
chore: draft form for stock indices touch/no-touch
Nuzhy-Deriv Jun 27, 2024
9b09d7c
chore: rise-and-fall, touch-notouch forms with config
Nuzhy-Deriv Jul 3, 2024
dac4ae8
chore: separate form component and fix issues
Nuzhy-Deriv Jul 3, 2024
fbca962
chore: simplified config and higherlower added
Nuzhy-Deriv Jul 4, 2024
02b96ee
fix: formname condtion for touchnotouch
Nuzhy-Deriv Jul 4, 2024
bc77482
chore: forms for all the contracts of forex, stock-indices
Nuzhy-Deriv Jul 5, 2024
5640e81
chore: store start dates in sessionStorage to update the form based o…
Nuzhy-Deriv Jul 5, 2024
0b5c86f
chore: update quill-ui
Nuzhy-Deriv Jul 10, 2024
d499e38
chore: added forms for digits
Nuzhy-Deriv Jul 15, 2024
c3beab7
fix: resolve merge conflicts
Nuzhy-Deriv Jul 15, 2024
b4a90b9
chore: fix reset css
Nuzhy-Deriv Jul 15, 2024
dd14106
chore: trade forms until synthetics
Nuzhy-Deriv Jul 15, 2024
20761fd
chore: trademanager and hook
Nuzhy-Deriv Jul 18, 2024
252abf8
chore: update starttime, expire type form fields
Nuzhy-Deriv Jul 18, 2024
c1c71c6
chore: update old fields based on new selection
Nuzhy-Deriv Jul 18, 2024
cdd29f9
fix: resolve merge conflicts
Nuzhy-Deriv Jul 18, 2024
17cebe4
chore: remove unused variable
Nuzhy-Deriv Jul 18, 2024
bc39f7b
chore: one form for all contracts
Nuzhy-Deriv Jul 18, 2024
b5e110e
chore: data hanlde until exprity type duration fields
Nuzhy-Deriv Jul 19, 2024
14dc8a4
fix: merge conflict resolve
Nuzhy-Deriv Jul 22, 2024
d5faa68
chore: setting expirydate in datepicker and update expiry date on change
Nuzhy-Deriv Jul 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
'keyword-spacing' : ['error', { after: true }],
'lines-between-class-members' : ['error', 'always', { exceptAfterSingleLine: true }],
'no-extra-semi' : 'error',
'no-console' : 'error',
// 'no-console' : 'error',
'no-else-return' : ['error', { allowElseIf: true }],
'no-multi-assign' : 0,
'no-param-reassign' : ['error', { props: false }],
Expand Down
398 changes: 211 additions & 187 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"@binary-com/binary-document-uploader": "^2.4.4",
"@binary-com/binary-style": "^0.2.26",
"@binary-com/webtrader-charts": "^0.6.1",
"@deriv-com/quill-ui": "^1.13.15",
"@deriv-com/quill-ui": "^1.13.19",
"@deriv/quill-icons": "^1.23.1",
"@livechat/customer-sdk": "4.0.2",
"canvas-toBlob": "1.0.0",
Expand Down
59 changes: 59 additions & 0 deletions src/javascript/app/common/trade_manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* eslint-disable class-methods-use-this */
import { triggerTradeChange } from '../hooks/events';

class TradeManager {
constructor() {
if (!window.trade) {
window.trade = {};
}
}

set(data) {
if (typeof data === 'object') {
const oldValues = {};
const newValues = {};
Object.entries(data).forEach(([key, value]) => {
if (window.trade[key] !== value) {
oldValues[key] = window.trade[key];
newValues[key] = value;
}
window.trade[key] = value;
});
if (Object.keys(newValues).length > 0) {
// Trigger a custom event with old and new values
window.dispatchEvent(new CustomEvent('tradeChange', {
detail: { oldValues, newValues },
}));

triggerTradeChange();
}
}
}

get(key) {
return window.trade[key];
}

getAll() {
return { ...window.trade };
}

// Method to clear all data from window.trade
clear() {
const oldValues = { ...window.trade };
window.trade = {};
window.dispatchEvent(new CustomEvent('tradeChange', {
detail: { oldValues, newValues: {} },
}));
triggerTradeChange();
}

// Method to check if a key exists in window.trade
has(key) {
return Object.prototype.hasOwnProperty.call(window.trade, key);
}
}

const tradeManager = new TradeManager();

export default tradeManager;
16 changes: 14 additions & 2 deletions src/javascript/app/hooks/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ class EventEmitter {
}
this.events[event].push(callback);
return () => {
this.events[event] = this.events[event].filter(cb => cb !== callback);
this.events[event] = this.events[event].filter((cb) => cb !== callback);
};
}

emit(event, data) {
if (this.events[event]) {
this.events[event].forEach(callback => callback(data));
this.events[event].forEach((callback) => callback(data));
}
}
}
Expand All @@ -45,6 +45,11 @@ const useCustomEvent = (eventName) => {
return hasNewChanges;
};

export const eventDispatcher = (element, eventName) => {
const event = new Event(eventName, { bubbles: true, cancelable: true });
element.dispatchEvent(event);
};

// Trigger functions
const triggerCustomEvent = (eventName) => {
eventEmitter.emit(eventName);
Expand All @@ -58,7 +63,14 @@ export const triggerMarketChange = () => triggerCustomEvent('marketChange');
export const useContractChange = () => useCustomEvent('contractChange');
export const triggerContractChange = () => triggerCustomEvent('contractChange');

// SesstionStorage Change
export const useSessionChange = () => useCustomEvent('sessionChange');
export const triggerSessionChange = () => triggerCustomEvent('sessionChange');

// Purchase Change
export const usePurchaseChange = () => useCustomEvent('purchaseChange');
export const triggerPurchaseChange = () => triggerCustomEvent('purchaseChange');

// Trade Change
export const useTradeChange = () => useCustomEvent('tradeChange');
export const triggerTradeChange = () => triggerCustomEvent('tradeChange');
Loading