diff --git a/package-lock.json b/package-lock.json index ebd90a372e2..c4f33ea4ed5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,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.11.7", + "@deriv-com/quill-ui": "^1.12.2", "@livechat/customer-sdk": "4.0.2", "canvas-toBlob": "1.0.0", "classnames": "2.2.5", @@ -2503,9 +2503,9 @@ } }, "node_modules/@deriv-com/quill-ui": { - "version": "1.11.7", - "resolved": "https://registry.npmjs.org/@deriv-com/quill-ui/-/quill-ui-1.11.7.tgz", - "integrity": "sha512-7ilcZSNUwiQnyFGNb2Kf4CLNegM7jO1rb1BhS2/Dz/2gYHzELZVcOSSde6/fKuQ3gqgGOwuXiJ3G/xrN2jF7gQ==", + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@deriv-com/quill-ui/-/quill-ui-1.12.2.tgz", + "integrity": "sha512-BJndKaXMdhLoYMuUxoDqOxHeeBq3vxSILosYM+7qA3ijr3GV4dtJSLAix+HpTJWG2bonJGdjebnyuk+GQA58Bw==", "dependencies": { "@deriv-com/quill-tokens": "^2.0.7", "@deriv/quill-icons": "^1.22.10", diff --git a/package.json b/package.json index f9db4b67717..15ba9b4b5fa 100644 --- a/package.json +++ b/package.json @@ -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.11.7", + "@deriv-com/quill-ui": "^1.12.2", "@livechat/customer-sdk": "4.0.2", "canvas-toBlob": "1.0.0", "classnames": "2.2.5", diff --git a/src/javascript/app/pages/trade/common.js b/src/javascript/app/pages/trade/common.js index f94c4691b02..eb34f389a74 100644 --- a/src/javascript/app/pages/trade/common.js +++ b/src/javascript/app/pages/trade/common.js @@ -3,7 +3,7 @@ const Symbols = require('./symbols'); const Tick = require('./tick'); const contractsElement = require('./contracts.jsx'); const marketsElement = require('./markets.jsx'); -const MarketDropdownElement = require('./markets/markets-dropdown.jsx'); +const MarketSelectorElement = require('./markets/market-selector.jsx'); const TabsElement = require('../bottom/tabs.jsx'); const formatMoney = require('../../common/currency').formatMoney; const ActiveSymbols = require('../../common/active_symbols'); @@ -63,7 +63,7 @@ const commonTrading = (() => { // All other Quill refactored components TabsElement.init(); - MarketDropdownElement.init(); + MarketSelectorElement.init(); }; /* diff --git a/src/javascript/app/pages/trade/contract.js b/src/javascript/app/pages/trade/contract.js index 008f380afc2..09f66cca820 100644 --- a/src/javascript/app/pages/trade/contract.js +++ b/src/javascript/app/pages/trade/contract.js @@ -126,7 +126,7 @@ const Contract = (() => { } barrier = form_barrier.barrier_category; - contracts.available.forEach((current_obj) => { + contracts?.available.forEach((current_obj) => { const contract_category = current_obj.contract_category; // for callput and callputequals, populate duration for both if (form === contract_category || (/callput/.test(form) && /callput/.test(contract_category))) { @@ -202,7 +202,7 @@ const Contract = (() => { const getContractCategories = () => { const contracts = Contract.contracts().contracts_for; const contract_categories = {}; - contracts.available.forEach((current_obj) => { + contracts?.available?.forEach((current_obj) => { const contract_category = current_obj.contract_category; const contract_barrier = current_obj.barrier_category; const contract_display = current_obj.contract_category_display; diff --git a/src/javascript/app/pages/trade/contracts.jsx b/src/javascript/app/pages/trade/contracts.jsx index 701eb49a5c7..cc0e4e251f8 100644 --- a/src/javascript/app/pages/trade/contracts.jsx +++ b/src/javascript/app/pages/trade/contracts.jsx @@ -1,12 +1,12 @@ import React from 'react'; import ReactDOM from 'react-dom'; import PropTypes from 'prop-types'; -import Defaults from './defaults'; +import { Divider, DropdownItem, DropdownTitle } from '@deriv-com/quill-ui'; +import Defaults, { PARAM_NAMES } from './defaults'; import { getElementById } from '../../../_common/common_functions'; -import { localize } from '../../../_common/localize'; import { triggerContractChange } from '../../hooks/events'; -class Contracts extends React.Component { +export class Contracts extends React.Component { constructor (props) { super(props); const { contracts, contracts_tree, selected } = props; @@ -38,31 +38,6 @@ class Contracts extends React.Component { } }; - openDropDown = () => { - if (this.state.contracts_tree.length < 1) return; - this.positionDropDown(); - this.setState({ open: true }); - }; - - closeDropDown = () => { - this.setState({ open: false }); - const el_dropdown = this.references.wrapper; - // reposition dropdown after the animation is finished. - setTimeout(() => el_dropdown.removeAttribute('style'), 500); - }; - - positionDropDown = () => { - const el_dropdown = this.references.wrapper; - const pos = el_dropdown.getBoundingClientRect(); - - if ((pos.x + pos.width + 10) > window.innerWidth) { - // 10 is padding right for the element - el_dropdown.style.left = `${window.innerWidth - (pos.x + pos.width + 10)}px`; - } else if ((pos.x + pos.width + 10) !== window.innerWidth) { - el_dropdown.removeAttribute('style'); - } - }; - saveRef = (name, node) => { this.references[name] = node; }; getCurrentType = () => { @@ -93,7 +68,6 @@ class Contracts extends React.Component { }; onContractClick = (formname) => { - this.closeDropDown(); if (formname === this.state.formname) { return; } // Notify for changes on contract. this.el_contract.value = formname; @@ -101,6 +75,10 @@ class Contracts extends React.Component { this.el_contract.dispatchEvent(event); this.setState({ formname }); + }; + + saveSelectedContract = (formname) => { + Defaults.set(PARAM_NAMES.CONTRACT_NAME,this.state.contracts[formname]); triggerContractChange(); }; @@ -110,65 +88,53 @@ class Contracts extends React.Component { const { contracts, contracts_tree, - open, formname, } = this.state; - const is_mobile = window.innerWidth <= 767; + return ( -