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

SmartTrader Redesign #660

Merged
merged 107 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
8c5a82d
chore: initial setup for redesign
prince-deriv Jun 12, 2024
2310f3b
fix: path update mistake
prince-deriv Jun 12, 2024
76acf5e
chore: update quill version
prince-deriv Jun 12, 2024
76462d1
Merge pull request #658 from prince-deriv/redesign
balakrishna-deriv Jun 13, 2024
86363ae
Meenu/[QUILL-1777] bottom tab draft (#661)
meenakshi-deriv Jun 26, 2024
afb2a98
Prince/ draft market dropdown container (#664)
prince-deriv Jul 11, 2024
e850770
Meenu market section subtask (#678)
meenakshi-deriv Jul 17, 2024
cb052f2
Purchase section improvements (#675)
prince-deriv Jul 17, 2024
8233c67
Purchase section improvements (#680)
prince-deriv Jul 17, 2024
f2e85ba
Meenu market scroll section (#679)
meenakshi-deriv Jul 18, 2024
361a172
Purchase section improvements (#681)
prince-deriv Jul 18, 2024
35477b9
Merge branch 'master' into redesign
prince-deriv Jul 18, 2024
a9f1c18
Purchase section improvements (#683)
prince-deriv Jul 18, 2024
669e559
Meenu add parser for section message (#682)
meenakshi-deriv Jul 18, 2024
d2ca4cd
fix: added offset (#684)
meenakshi-deriv Jul 18, 2024
36bc4cf
Purchase section improvements (#685)
prince-deriv Jul 19, 2024
32d0587
Nuzhy/trade parameters UI [Quill] (#674)
Nuzhy-Deriv Jul 22, 2024
16bb30c
Nuzhy/starttime now option issue (#690)
Nuzhy-Deriv Jul 22, 2024
dcf07cd
Purchase section improvements (#693)
prince-deriv Jul 22, 2024
bd3a615
fix: market selector not returning to default value when empty search…
jia-deriv Jul 22, 2024
17556e0
Meenu last digit tab (#691)
meenakshi-deriv Jul 23, 2024
21a08cd
Jia/QUILL-1783/Fix the UI issues brought by Quill CSS (#694)
jia-deriv Jul 23, 2024
e28b94f
Prince/Contract type forname fixes (#696)
prince-deriv Jul 23, 2024
e1a4143
fix: responsive fix for purchase section (#695)
meenakshi-deriv Jul 24, 2024
992b154
fix: fixes for purchase responsive (#698)
meenakshi-deriv Jul 24, 2024
855796f
fix: fixed width for contract details (#699)
meenakshi-deriv Jul 25, 2024
0d6f3ea
Jia/QUILL-1807/Restricted Page (#697)
jia-deriv Jul 25, 2024
660818b
Meenu scrollbar style and chart (#700)
meenakshi-deriv Jul 25, 2024
38fa3e4
chore: added page loader (#701)
prince-deriv Jul 26, 2024
06c448a
Merge branch 'master' into redesign
prince-deriv Jul 26, 2024
9ec72cb
fix: fixed arrow color (#702)
meenakshi-deriv Jul 26, 2024
80ed9f6
Prince/Loading and color issues (#705)
prince-deriv Jul 26, 2024
03f4c88
Meenu/fix: added content and fixed image (#706)
meenakshi-deriv Jul 26, 2024
8e9041b
chore: apply digits ticker color (#708)
prince-deriv Jul 26, 2024
11c4887
chore: center trade section (#709)
prince-deriv Jul 26, 2024
56b86f2
Meenu/fix: updated responsive style for loader (#710)
meenakshi-deriv Jul 29, 2024
52dfe3a
fix: deposit button and build error (#713)
prince-deriv Jul 29, 2024
63c7700
Meenu/fix: wrap id for trading component (#712)
meenakshi-deriv Jul 29, 2024
23627e9
fix: vulnerable dependency package (#714)
prince-deriv Jul 29, 2024
75051de
chore: fixed showing correct fields (#715)
prince-deriv Jul 29, 2024
84b4f59
Meenu/fix: fixed scroll for contract type (#716)
meenakshi-deriv Jul 29, 2024
ff83f05
fix: translation issue (#717)
prince-deriv Jul 29, 2024
43ef329
chore: add localize (#719)
jia-deriv Jul 29, 2024
f57b58a
Prince/Loading issue (#718)
prince-deriv Jul 29, 2024
c600bd1
fix: popup (#720)
prince-deriv Jul 29, 2024
d5d5a30
Meenu/fix: fixed layout issue (#722)
meenakshi-deriv Jul 30, 2024
646c9bc
Prince/Fixed bottom tabs (#724)
prince-deriv Jul 30, 2024
8ea7893
chore: fix explanation strings (#727)
prince-deriv Jul 30, 2024
fd10aea
Meenu/ fix for scrollbar explanation (#726)
meenakshi-deriv Jul 30, 2024
c41e4eb
fix: updated translation (#728)
meenakshi-deriv Jul 30, 2024
666e227
Nuzhy/trade parameters UI (#688)
Nuzhy-Deriv Jul 31, 2024
0551228
fix: min width for audit section (#729)
meenakshi-deriv Jul 31, 2024
ec20aa3
fix: table profit visibility (#730)
prince-deriv Jul 31, 2024
8069861
Meenu/fix: guide btn fix (#732)
meenakshi-deriv Jul 31, 2024
256162a
Nuzhy/allow equals checkbox, barrier tooltips (#731)
Nuzhy-Deriv Jul 31, 2024
bc80ae2
fix: loader behavior on different pages (#733)
prince-deriv Jul 31, 2024
b25339d
Meenu/fix: fixed contract page z index for test (#734)
meenakshi-deriv Aug 1, 2024
32c94fe
chore: fix subtask for not available page (#725)
jia-deriv Aug 1, 2024
ddf7892
Nuzhy/trade forms field spacing (#736)
Nuzhy-Deriv Aug 1, 2024
74c5be4
Prince/ Restricted pages fix (#739)
prince-deriv Aug 1, 2024
b5a9145
fix: forms ui fixes (#740)
Nuzhy-Deriv Aug 1, 2024
a834f06
fix: laoder issue (#741)
jia-deriv Aug 1, 2024
dca3000
Prince/no error for demo no balance (#742)
prince-deriv Aug 1, 2024
6754dc6
Nuzhy/trade forms UI fixes (#743)
Nuzhy-Deriv Aug 1, 2024
7cc0b92
Merge branch 'master' into redesign
prince-deriv Aug 2, 2024
4ac05f5
chore: fix button text (#744)
jia-deriv Aug 2, 2024
89ce4d8
fix: image issue on DE (#745)
prince-deriv Aug 2, 2024
5e80046
fix: code suggestions (#746)
prince-deriv Aug 2, 2024
51b7251
Prince/ Code fix (#747)
prince-deriv Aug 2, 2024
17b869e
Revert "Prince/ Code fix (#747)" (#749)
prince-deriv Aug 2, 2024
e905c6d
fix: barrier offset fields to different rows (#750)
Nuzhy-Deriv Aug 2, 2024
fa6f350
fix: condition to check enddate change to prevent ws requests (#751)
Nuzhy-Deriv Aug 2, 2024
14fea7a
fix: unreset errrors (#752)
prince-deriv Aug 2, 2024
a55678e
Jia/_/fix not available page color (#756)
jia-deriv Aug 5, 2024
5602639
fix: close contract details on esc button (#757)
meenakshi-deriv Aug 5, 2024
214ea56
fix: hamburger issue (#758)
jia-deriv Aug 5, 2024
9ab43f1
Nuzhy/pr comments (#755)
Nuzhy-Deriv Aug 5, 2024
068b4f3
chore: apply request changes (#759)
jia-deriv Aug 5, 2024
4040ddc
chore: spacer for centering title (#760)
prince-deriv Aug 5, 2024
05a7eb2
Meenu/fix: fixed pr comments (#761)
meenakshi-deriv Aug 5, 2024
d6de3fe
fix: added margin for loaders (#762)
meenakshi-deriv Aug 5, 2024
efc4598
fix: barrier inputs (#764)
prince-deriv Aug 6, 2024
4ef9b9d
fix: hidden items on bigger screen (#765)
prince-deriv Aug 6, 2024
be46503
fix: fixed height issue for popup and updated guide id (#766)
meenakshi-deriv Aug 6, 2024
453dd8f
nuzhy/_/actionsheet height to be content size (#768)
Nuzhy-Deriv Aug 6, 2024
9b88e2d
fix: datepicker min date config issue (#770)
Nuzhy-Deriv Aug 7, 2024
073eafe
Nuzhy/dataManager (#763)
Nuzhy-Deriv Aug 7, 2024
7273be8
fix: barrier value on trade type change issue (#771)
Nuzhy-Deriv Aug 7, 2024
3f9058e
fix: hide startime row issue (#772)
Nuzhy-Deriv Aug 7, 2024
3eb3e7e
fix: temp patch for calendar days background (#773)
prince-deriv Aug 7, 2024
761dcbe
Nuzhy/_/empty field issue (#776)
Nuzhy-Deriv Aug 8, 2024
35871d0
Merge branch 'master' into redesign
prince-deriv Aug 8, 2024
31b23db
Prince/fix digit chart issue (#778)
prince-deriv Aug 8, 2024
70793ea
nuzhy/firefox input type number spin button issue (#780)
Nuzhy-Deriv Aug 8, 2024
68ef580
Prince/Code cleanup (#777)
prince-deriv Aug 8, 2024
d6758db
fix: added box-shadow to custom dropdowns (#781)
Nuzhy-Deriv Aug 8, 2024
44fd237
Meenu/fix: fixed audit page (#779)
meenakshi-deriv Aug 8, 2024
9d53f1e
Maryia/refactor: Add timeout cleanups & assist with nit-picks fixes (…
maryia-deriv Aug 8, 2024
d45fd8d
fix: purchase issue on startime change (#783)
Nuzhy-Deriv Aug 9, 2024
249b7ec
Nuzhy/QUILL-1934/barrier fields issue (#784)
Nuzhy-Deriv Aug 9, 2024
dd87956
fix: enddate value format (#785)
Nuzhy-Deriv Aug 9, 2024
92d1f49
fix: table alignment on other language (#789)
prince-deriv Aug 9, 2024
b6563fe
fix: selected enddate issue on market change (#788)
Nuzhy-Deriv Aug 9, 2024
dc685ea
fix: close the dropdown for same contract selection (#786)
Nuzhy-Deriv Aug 9, 2024
c6b9022
Meenu/fix: updated quill version (#787)
meenakshi-deriv Aug 9, 2024
56e07e6
fix: guide issue on purchase error (#790)
prince-deriv Aug 9, 2024
a832e61
Nuzhy/nit picks (#791)
Nuzhy-Deriv Aug 12, 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
1 change: 1 addition & 0 deletions build/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const release_config = {

const node_modules_paths = {
binary_style: 'node_modules/@binary-com/binary-style',
quill : 'node_modules/@deriv-com/quill-ui',
};

const config = {
Expand Down
1 change: 1 addition & 0 deletions build/cssmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = {
],
dest: `${global.dist}/css/common.min.css`,
},
{ src: `${global.dist}/css/reset.css`, dest: `${global.dist}/css/reset.min.css` },
{ src: `${global.dist}/css/app.css`, dest: `${global.dist}/css/app.min.css` },
{ src: `${global.dist}/css/static.css`, dest: `${global.dist}/css/static.min.css` },
],
Expand Down
2 changes: 1 addition & 1 deletion build/postcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = function (grunt) {
],
},
dist: {
src: `${global.dist}/css/{app,common,static}.css`,
src: `${global.dist}/css/{app,common,static,reset}.css`,
},
};
};
4 changes: 4 additions & 0 deletions build/webpack/config_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ const commonConfig = (grunt) => ({
},
],
},
{
test: /\.css$/,
use : ['style-loader', 'css-loader'],
},
],
},
watch : false,
Expand Down
18,849 changes: 12,125 additions & 6,724 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"devDependencies": {
"@babel/core": "7.24.0",
"@babel/eslint-parser": "7.23.10",
"@babel/parser": "7.1.2",
"@babel/parser": "7.25.0",
"@babel/plugin-proposal-decorators": "^7.24.7",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-class-properties": "^7.24.7",
Expand All @@ -44,6 +44,7 @@
"commander": "2.12.2",
"connect-livereload": "0.6.0",
"connect-modrewrite": "^0.10.2",
"css-loader": "^7.1.2",
"deep-diff": "0.3.8",
"emphasize": "7.0.0",
"enzyme": "3.3.0",
Expand Down Expand Up @@ -87,6 +88,7 @@
"react-render-html": "0.6.0",
"sass": "^1.77.6",
"sitemap": "1.13.0",
"style-loader": "^4.0.0",
"stylelint": "15.11.0",
"stylelint-formatter-pretty": "1.0.3",
"stylelint-selector-bem-pattern": "3.0.1",
Expand All @@ -103,7 +105,9 @@
"@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.30",
"@deriv/deriv-api": "^1.0.15",
"@deriv/quill-icons": "^1.23.1",
"@livechat/customer-sdk": "4.0.2",
"canvas-toBlob": "1.0.0",
"classnames": "2.2.5",
Expand All @@ -112,6 +116,7 @@
"davidshimjs-qrcodejs": "0.0.2",
"event-source-polyfill": "0.0.9",
"highstock-release": "5.0.14",
"html-react-parser": "^5.1.10",
"jquery": "3.5.1",
"jquery.scrollto": "2.1.2",
"js-cookie": "2.2.0",
Expand All @@ -131,6 +136,11 @@
"peerDependencies": {
"circular-dependency-plugin": "5.2.2"
},
"overrides": {
"braces": "^3.0.3",
"@babel/parser": "7.25.0",
"@babel/plugin-proposal-optional-chaining": "7.22.5"
},
"engines": {
"node": "18.x"
},
Expand Down
2 changes: 1 addition & 1 deletion scripts/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ exports.sections_config = {
'': { // '' is the default section when no 'section' specified in pages.js (to avoid adding 'app' as section for all)
path : '',
js_files : ['vendor', 'binary'],
css_files: ['common.min', 'app.min', 'static.min'],
css_files: ['common.min', 'app.min', 'static.min','reset.min'],
has_pjax : true,
},
};
Expand Down
108 changes: 107 additions & 1 deletion scripts/js_texts/extracted_strings_app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/javascript/_autogenerated/ach.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/javascript/_autogenerated/de.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/javascript/_autogenerated/es.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/javascript/_autogenerated/fr.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/javascript/_autogenerated/id.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/javascript/_autogenerated/it.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/javascript/_autogenerated/pl.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/javascript/_autogenerated/pt.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/javascript/_autogenerated/ru.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/javascript/_autogenerated/th.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/javascript/_autogenerated/vi.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/javascript/_autogenerated/zh_cn.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/javascript/_autogenerated/zh_tw.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/javascript/_common/localize.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const moment = require('moment');
const { urlLang } = require('./language');
require('moment/min/locales');
const template = require('./utility').template;

Expand All @@ -15,6 +16,12 @@ const Localize = (() => {

const index = text.replace(/[\s|.]/g, '_');

const lang = urlLang().toUpperCase();

const strings = typeof texts_json !== 'undefined' ? texts_json : {};
prince-deriv marked this conversation as resolved.
Show resolved Hide resolved

localized_texts = strings[lang];

text = (localized_texts && localized_texts[index]) || text;

// only use template when explicitly required
Expand Down
31 changes: 5 additions & 26 deletions src/javascript/app/base/binary_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const isStorageSupported = require('../../_common/storage').isStorageSupported;
const ThirdPartyLinks = require('../../_common/third_party_links');
const urlFor = require('../../_common/url').urlFor;
const createElement = require('../../_common/utility').createElement;
const NotAvailable = require('../pages/trade/not-available.jsx');

const BinaryLoader = (() => {
let container;
Expand Down Expand Up @@ -152,9 +153,9 @@ const BinaryLoader = (() => {
if (config.no_blocked_country && Client.isLoggedIn() && Client.isOptionsBlocked()) {
displayMessage(error_messages.options_blocked());
} else if (Client.isLoggedIn() && Client.isOfferingBlocked()) {
displayMessage(error_messages.offerings_blocked());
displayUnavailable({ body: error_messages.offerings_blocked() });
} else if (config.no_mf && Client.isLoggedIn() && Client.isAccountOfType('financial')) {
displayUnavailable();
displayUnavailable({ body: localize('Unfortunately, this trading platform is not available for EU Deriv account. Please switch to a non-EU account to continue trading.') });
}
});

Expand Down Expand Up @@ -193,35 +194,13 @@ const BinaryLoader = (() => {
}
};

const displayUnavailable = () => {
const displayUnavailable = (props) => {
const content = container.querySelector('#content .container');
if (!content) {
return;
}

const div_container = createElement('div', { class: 'platform-unavailable' });
const inner_container = createElement('div', { class: 'platform-unavailable-inner' });
const h1_title = createElement('h1', { text: localize('SmartTrader is unavailable for this account'), class: 'platform-unavailable-inner-title' });
const message = createElement('div',
{
text: localize(
'Unfortunately, this trading platform is not available for EU Deriv account. Please switch to a non-EU account to continue trading.'
),
class: 'platform-unavailable-inner-message',
});
const button = createElement('button', { text: localize('Switch to another account'), class: 'platform-unavailable-inner-button' });

div_container.appendChild(inner_container);
inner_container.appendChild(h1_title);
inner_container.appendChild(message);
inner_container.appendChild(button);

button.addEventListener('click', (event) => {
document.getElementById('acc_switcher').click();
event.stopPropagation();
});

content.html(div_container);
NotAvailable.init({ title: localize('SmartTrader is unavailable for this account'), ...props });
};

const handleNotAuthenticated = () => {
Expand Down
8 changes: 8 additions & 0 deletions src/javascript/app/base/clock.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,17 @@ const Clock = (() => {
});
};

const getLocalTime = (time) => {
const gmt_time_str = time.replaceAll('\n', ' ');
const local_time = moment.utc(gmt_time_str, 'YYYY-MM-DD HH:mm:ss').local();

return local_time.format('YYYY-MM-DD HH:mm:ss Z');
};

return {
startClock,
showLocalTimeOnHover,
getLocalTime,
setExternalTimer: (func) => { fncExternalTimer = func; },
};
})();
Expand Down
38 changes: 38 additions & 0 deletions src/javascript/app/common/active_symbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ const submarket_order = {
random_nightly : 20,
};

const marketOrder = [
'forex',
'indices',
'cryptocurrency',
'commodities',
'baskets',
'synthetics',
];

const derived = ['baskets','synthetics'];

const ActiveSymbols = (() => {
const groupBy = (xs, key) => (
xs.reduce((rv, x) => {
Expand Down Expand Up @@ -218,6 +229,30 @@ const ActiveSymbols = (() => {
return all_symbols;
};

const sortObjectByKeys = (obj, order) => {
const orderedObj = {};
const remainingObj = {};
prince-deriv marked this conversation as resolved.
Show resolved Hide resolved

// Add keys in the specified order
order.forEach(key => {
// eslint-disable-next-line no-prototype-builtins
if (obj.hasOwnProperty(key)) {
orderedObj[key] = obj[key];
}
});

// Add any remaining keys that were not specified in the order array
Object.keys(obj).forEach(key => {
// eslint-disable-next-line no-prototype-builtins
if (!orderedObj.hasOwnProperty(key)) {
remainingObj[key] = obj[key];
}
});

// Combine ordered keys and remaining keys
return { ...orderedObj, ...remainingObj };
};

return {
getMarkets,
getSubmarkets,
Expand All @@ -229,6 +264,9 @@ const ActiveSymbols = (() => {
getSymbolsForMarket,
sortSubmarket,
getAvailableUnderlyings,
marketOrder,
derived,
sortObjectByKeys,
};
})();

Expand Down
59 changes: 59 additions & 0 deletions src/javascript/app/common/contract_manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* eslint-disable class-methods-use-this */
import { triggerContractChange } from '../hooks/events';

class ContractManager {
constructor() {
if (!window.contract) {
window.contract = {};
Copy link
Contributor

@maryia-deriv maryia-deriv Aug 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please explain why was this approach selected to store contract data in the global window object? same for window.trade & window.purchase.
Why not localStorage or some custom store accessible from any point of application if you're trying to avoid circular dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These data are only available in the current session, so upon browser refresh we want these data to go away. We are leveraging on global variables to observe and fully use the state features of react.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if you want these data to do away on browser refresh, why not sessionStorage in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

session storage doesn't go away after refresh.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prince-deriv seems the contract object is only used in this file. Is there any reason we should set it in window?
Can we set it as a class member object? or, use a separate context object just for contract?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are refactoring this to use class member, since the QA is almost done with testing and we no longer need the window data for testing.

}
}

set(data) {
if (typeof data === 'object') {
prince-deriv marked this conversation as resolved.
Show resolved Hide resolved
const oldValues = {};
const newValues = {};
Object.entries(data).forEach(([key, value]) => {
if (window.contract[key] !== value) {
oldValues[key] = window.contract[key];
newValues[key] = value;
}
window.contract[key] = value;
});
if (Object.keys(newValues).length > 0) {
// Trigger a custom event with old and new values
window.dispatchEvent(new CustomEvent('contractChange', {
detail: { oldValues, newValues },
}));

triggerContractChange();
}
}
}

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

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

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

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

const contractManager = new ContractManager();

export default contractManager;
13 changes: 13 additions & 0 deletions src/javascript/app/common/currency.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
const tradeManager = require('./trade_manager').default;
const CurrencyBase = require('../../_common/base/currency_base');
const localize = require('../../_common/localize').localize;

const getCurrencyFullName = (currency) => CurrencyBase.isCryptocurrency(currency) ? `${CurrencyBase.getCurrencyName(currency)} (${CurrencyBase.getCurrencyDisplayCode(currency)})` : currency;

const getCurrencyList = (currencies) => {
const currency_list = {
fiat : [],
crypto: [],
};
const $currencies = $('<select/>');
const $fiat_currencies = $('<optgroup/>', { label: localize('Fiat') });
const $cryptocurrencies = $('<optgroup/>', { label: localize('Crypto') });
Expand All @@ -12,6 +17,14 @@ const getCurrencyList = (currencies) => {
const currency_name = getCurrencyFullName(currency);
(CurrencyBase.isCryptocurrency(currency) ? $cryptocurrencies : $fiat_currencies)
.append($('<option/>', { value: currency, text: currency_name }));
if (CurrencyBase.isCryptocurrency(currency)) {
currency_list.crypto.push({ value: currency, text: currency_name });
} else {
currency_list.fiat.push({ value: currency, text: currency_name });
}
});
tradeManager.set({
currency_list,
});

return $currencies.append($fiat_currencies.children().length ? $fiat_currencies : '').append($cryptocurrencies.children().length ? $cryptocurrencies : '');
Expand Down
Loading
Loading