Skip to content

Commit

Permalink
Vinu/fix: fixed minor code smells in bot-web-ui (#9822)
Browse files Browse the repository at this point in the history
* fix: fixed minor code smells in bot-web-ui

* fix: added types for gtm in TCoreStores

* fix: removed unnnecessary comments

* Farzin/WALL-1628/Side Note issue on staging environment (#9820)

* fix(cashier): 🐛 fix

* fix(cashier): 🐛 fix

* fix(cashier): 🐛 fix

* fix(cashier): 🐛 fix

* fix(cashier): 🐛 fix

* fix: don't show side note in FIAT withdrawal page

---------

Co-authored-by: Farzin Mirzaie <farzin@deriv.com>
Co-authored-by: Nijil Nirmal <nijil@deriv.com>

* farhan/feat: add useSettings hook to @deriv/api (#9805)

* chore: added useSettings to @deriv/api

* chore: combine get_settings with set_settings

* refactor: change function name

* chore: return all mutation data

* chore: export hook

* refactor: types and mutation function name

* translations: 📚 sync translations with crowdin (#9836)

Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>

* fix: add optional chaining to prevent error (#9838)

* farzin/feat(wallets): 📦 add `@deriv/wallets` workspace (#9756)

* fix(cashier): 🐛 fix unable to access CFD-DerivX transfer

* feat(wallets): 📦 add `@deriv/wallets` workspace

* fix(wallets): 💚 fix CI build

* feat(api): ✨ share a single instance of `QueryClient` in `APIProvider`

* Merge branch 'master' into farzin/next

---------

Co-authored-by: Farzin Mirzaie <farzin@deriv.com>

* farhan/WALL-1583/Add useLandingCompany hook to @deriv/api (#9785)

* feat: added use-authorize hook taken from sergei pr

Co-authored-by: Sergei Baranovski <120570511+sergei-deriv@users.noreply.github.com>

* chore: sorted imports for use-authorize

Co-authored-by: Sergei Baranovski <120570511+sergei-deriv@users.noreply.github.com>

* chore: moved default empty string in use-authorize

* chore: incorporated code reviews

* chore: added useLandingCompany into api package

* chore: added useSettings to @deriv/api

* chore: get country_code from user settings instead of authorize

* chore: combine get_settings with set_settings

* fix: change request type for landing_company

* chore: combine get_settings with set_settings

* refactor: change function name

* chore: add missing dependencies for useLandingCompany return data

* chore: return all mutation data

* chore: export hook

* refactor: types and mutation function name

* refactor: use-landing-company-hook

* fix: remove dependency

---------

Co-authored-by: adrienne-rio <adrienne@deriv.com>
Co-authored-by: Sergei Baranovski <120570511+sergei-deriv@users.noreply.github.com>

* adrienne/feat: added use-get-status-account hook (#9808)

* feat: added use-get-status-account hook

* chore: updated comments

* fix: make use-accounts-list dependent on use-get-account-status hook

* chore: incorporated review changes

* fix: fixed typescript issue in wallets

* farzin/feat: add `useTradingAccountsList`, `useActiveTradingAccount`, and `useActiveAccount` hooks (#9824)

* refactor(api): ♻️ clean-up

* feat(api): ✨ add `useTradingAccountsList`, `useActiveTradingAccount`, and `useActiveAccount` hooks

---------

Co-authored-by: Farzin Mirzaie <farzin@deriv.com>

* Shafin/bot 368/feat  draggable transaction modal (#9137)

* feat: transaction details modal

* feat: complete test cases for TransactionDetails modal

* chore: fix code smells

* chore: fix code smells

* chore: remove code smells

* chore: redeploy

* chore: move transaction details types to types folder

* feat: add draggable modal component

* chore: finish test cases for draggable component

* chore: add header props to draggable

* chore: show enrty and exit tick if available

* fix: transaction scroll css issue fix

* fix: update key with data for divider inside transaction details modal

* fix: update buy price to have decimal value

* fix: css issue on modal height and fixed decimal profit/loss

* fix: fix style for modal getting cut

* fix: modal css issue after build

* fix: decrease the modal height for edge cutting issue

* fix: test case

* Merge branch 'master' into shafin/BOT-368/feat--draggable-transaction-modal

* fix: not closing on responsive view issue

* fix: test case

* fix: reduce preview workspace control z-index

* farabi/bot-385/embed hotjar attribution (#9419)

* fix: added new attributes for hotjar

* refactor: separated hotjar script to a function in utils

* fix: updated attribute

* fix: added optional for client login id

* chore: added comment for attribution code

* Arshad/ WALL-833/ show correct platform on trader's hub onboarding (#9680)

* fix: show correct platform on trader's hub onboarding

* test: ✅ added onboarding test for financial restricted countries

* fix: fixed cfd restricted countries

* chore: use sass instead of node-sass (#8916)

* chore: use sass instead of node-sass

* docs: remove node-sass from readme file

* docs: fix typo in readme file

* chore: retrigger ci tests

* fix: ci test failed

---------

Co-authored-by: Ali(Ako) Hosseini <ali.hosseini@deriv.com>

* Kate / OPT-347 / Opening the Duration Tab for the first time will show incorrect expiry time (#9732)

* chore: draft

* feat: expant function and hardcoded date

* refactor: add usage moment library

* chore: remove extra space

* likhith/fix: sending empty payload to non idv countries (#9739)

* fix: sending empty payload to non idv countries

* fix: sending empty payload to non idv countries

* Farabi/bot 399/hide bot too risky modal (#9542)

* fix: removed bot too risky modal and updated stop icon

* fix: added toast notification when user stops bot

* fix: fixed snack bar for quick strategy run

* fix: added close function on snackbar

* fix: added clear and reset timeout on hovering on toast

* fix: added test case for bot-stop-notification

* fix: stop bot snack bar appearing with no trade again

* translations: 📚 sync translations with crowdin (#9856)

Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>

* FarhanNurzi/feat: WALL-1574/Add useAvailableAccounts hook to @deriv/api (#9786)

* feat: added use-authorize hook taken from sergei pr

Co-authored-by: Sergei Baranovski <120570511+sergei-deriv@users.noreply.github.com>

* chore: sorted imports for use-authorize

Co-authored-by: Sergei Baranovski <120570511+sergei-deriv@users.noreply.github.com>

* chore: moved default empty string in use-authorize

* chore: incorporated code reviews

* chore: added useLandingCompany into api package

* chore: added useLandingCompany into api package

* chore: added useAvailableAccounts and useAccountTypes hooks into api package

* chore: added useSettings to @deriv/api

* chore: get country_code from user settings instead of authorize

* chore: combine get_settings with set_settings

* fix: change request type for landing_company

* chore: combine get_settings with set_settings

* refactor: change function name

* chore: add landing_company field to each account types

* chore: add missing dependencies for useLandingCompany return data

* chore: return all mutation data

* chore: export hook

* refactor: types and mutation function name

* refactor: use-landing-company-hook

* fix: remove dependency

* fix: remove dependency

* refactor: use-available-accounts hook

* fix: review comments, remove gaming accounts

* refactor: separate accounts usememo

---------

Co-authored-by: adrienne-rio <adrienne@deriv.com>
Co-authored-by: Sergei Baranovski <120570511+sergei-deriv@users.noreply.github.com>

* thisyahlen/chore: add useTradingPlatformAvailableAccounts to deriv api (#9810)

* chore: add useTradingPlatformAvailableAccounts to deriv api

* fix: type repetition annd fallback

* refactor: repetition

* fix: empty commit

* fix: empty commit

* fix: comment

* thisyahlen/feat: wallet-list-desktop (#9829)

* fix(cashier): 🐛 fix unable to access CFD-DerivX transfer

* feat(wallets): 📦 add `@deriv/wallets` workspace

* fix(wallets): 💚 fix CI build

* feat(api): ✨ share a single instance of `QueryClient` in `APIProvider`

* Merge branch 'master' into farzin/next

* chore: add wallet header list data for desktop

---------

Co-authored-by: Farzin Mirzaie <farzin@deriv.com>

* farhan/feat: Added Wallet Carousel to @deriv/wallets (#9847)

* fix(cashier): 🐛 fix unable to access CFD-DerivX transfer

* feat(wallets): 📦 add `@deriv/wallets` workspace

* fix(wallets): 💚 fix CI build

* feat(api): ✨ share a single instance of `QueryClient` in `APIProvider`

* Merge branch 'master' into farzin/next

* chore: created mobile wallets carousel

Co-authored-by: Sergei Baranovski <120570511+sergei-deriv@users.noreply.github.com>

---------

Co-authored-by: Farzin Mirzaie <farzin@deriv.com>
Co-authored-by: Sergei Baranovski <120570511+sergei-deriv@users.noreply.github.com>

* thisyahlen/chore: update wallet loginids (#9866)

* farzin/refactor(api): ♻️ clean-up (#9864)

Co-authored-by: Farzin Mirzaie <farzin@deriv.com>

* adrienne/feat: added svg bundling for wallets (#9871)

* feat: added svg bundling for wallets

* chore: removed assets folder in wallets

* henry/webrel-1160/hotfix: space issue dropdown (#9898)

* fix: space issue dropdown

* fix: resolve comment

* fix: comment

* Update packages/components/src/components/dropdown/dropdown.scss

* fix: empty commit

---------

Co-authored-by: Maryia <103177211+maryia-deriv@users.noreply.github.com>

* fix: overwritten styles (#9899)

* fix: overwritten styles

* fix: overwritten styles

* Ameerul /WEBREL-1159 Sort by column alignment in P2P Buy/Sell page is off (#9876)

* chore: fixed sort dropdown alignment

* chore: changed styling for dropdown

* george / PRODQA-1316 / Transfer from Tradershub validation (#9908)

* fix: 🚑 fix active container for TH transfer, fix insufficient balance check

* test: 🐛 fix tests

* fix: 🚑 fix 'Insufficient balance' condition

* translations: 📚 sync translations with crowdin (#9912)

Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>

* translations: 📚 sync translations with crowdin (#9917)

Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>

* Hirad-Hamza-ShonTzu/Feature revamp compare account re-deployment (#9611)

* feat: initializing the compare account implementation

* feat: icon reusable component v1.0

* feat: icon reusable component v1.1

* feat: icon reusable component v1.1.1

* feat: initialize compare cfd account page (todo:css)

* feat: blank compare cfd accounts page & navi done

* feat: mobile view

* fix: compare-accounts naming convention

* fix: updated path import

* fix: reverted icons.js changes

* fix: compare-cfds -> compare-accounts

* feat: reusable component v1.2

* feat: reusable component v1.2.1

* feat: icon reusable component added v1.3

* feat: reusable component for Icons

* feat: reusable component for Icons refactor

* feat: reusable component for Icons refactor v1.2

* feat: description div added

* feat: description with title +icon is added

* feat: platform label + icon component padding added

* chore: labuan leverage updated

* chore: css issue fixed for Cards

* feat: carousel added with sorting o f MT5 accounts

* feat: carousel arrow background and container added

* chore: added dxtrade in the card for dynamic rendering with type fixes

* chore: changes in platform label header with respect to props data

* chore: icons updated because of white line issue in icons

* chore: change the components css name and other naming convention tweaks

* refactor: suggestions implemented

* refactor: convert carousel button into one

* feat: initial commit for starting collaboration

* feat: added the button placeholder

* feat: added new banner to cfd cards

* refactor: make the banner smaller

* fix: added condition to show banner for derivez and ctrader only

* refactor: changed the types and applied suggestions

* refactor: removed the invalide shortcode for dxtrade

* refactor: round up patches based on reviews

* fix: round up patch 2 based on review

* Update packages/cfd/src/Containers/cfd-compare-accounts/cfd-compare-accounts.scss

Co-authored-by: Muhammad Hamza <120543468+hamza-deriv@users.noreply.github.com>

* refactor: button width

* refactor: button classname

* chore: fix css of underline

* chore: added redirection to homepage in case of modals

* fix: circle ci failed due to wrong type of client function

* chore: added the disabled property for the Added accounts

* chore: added condition for the dxtrade

* chore: rearrange block scoped variables

* chore: fix css of labuan tooltip with removal of commented code

* chore: responsive view fixes

* feat: demo accounts added for low risk

* feat: demo accounts label added and swap-free account creation fixed

* chore: added derivx account creation flow

* refactor: replace ternary operators with if-else

* chore: remove unused jurisdiction

* feat: demo account compare implemetation tweaks as per design

* feat: rectified the Demo title as per design

* chore: font weigth of instruments as per design

* feat: Eu flow for DIEL

* feat: changes in the icons label and correction in EU flow

* chore: addded translations demo title and rename baskets

* chore: rename icon type

* chore: final changes prop drilling instead of observer EU flow finalized

* fix: hidding deriv ez

* fix: EU flow platform label change

* feat: test case for description added

* feat: platform label test case added

* feat: title icon test case added

* feat: title icon test case added

* chore: fix test case description + instruments icon test added

* refactor: blank spaces removed

* chore: cfd-instruments-label test added

* chore: test file added cfd-instrument-label

* feat: button partial test case added

* chore: added more test case for Button component

* feat: added test case for compare-account-card

* chore: merge conflicts

* chore: test for cfd-compare-accounts added

* feat: derivX demo

* chore: added testcase for dxtrade in button

* fix: dxtrade for australian clients

* fix: swapfree account creation added

* fix: comapre account fixes first round

* fix: remove the css because scroll not working

* fix: renamed variable + icons

* fix: cursor not allowed on instrument icons

* fix: fixed the circle ci issue

* fix: fixed one of our test issues

* refactor: review comments resolved

* fix: changing the text of mf accounts to pass the tests

* fix: made changes according to suggestions

* fix: made changes according to suggestions

* fix: fixed the test case issues

* chore: added s to spread(s)

* chore: fixed capitalization

* chore: line split

* fix: failing test case

* fix: updated markets offerings for MT5 Financial Labuan

* fix: Other CFDs --> Other CFDs Platform

* fix: removed standard/micro from DerivX Forex label

* refactor: optimised code

* fix: icon size inconsistencyn mobile VP

* refactor: css refactoring to reflect figma as much as possible

* refactor: minor css fixes

* fix: fixed

* style: added bottom padding for mobile

* fix: fixed the build issue

* chore: re running the tests

* fix: subtasks

* chore: typo

* style: position the tooltip to be center within the card

* style: resize width for word-wrap

* chore: d and r should be lowercase dispute and resolution

* fix: fixing sonar cloud issues

* fix: making changes to pass the tests

---------

Co-authored-by: hamza-deriv <hamza.muhammad@regentmarkets.com>
Co-authored-by: shontzu-deriv <shon.tzu@regentmarkets.com>
Co-authored-by: shontzu <108507236+shontzu-deriv@users.noreply.github.com>
Co-authored-by: Muhammad Hamza <120543468+hamza-deriv@users.noreply.github.com>

* adrienne/chore: added eslint and stylelint for wallets and renamed css variables (#9877)

* feat: added stylelint for wallets for bem convention

* feat: added stylelint for wallets for bem convention

* chore: added import sorts for wallets and bem convention checking

* chore: removed unused dependencies in wallets

* Arshad/Matin/WALL-1226/Dynamic leverage for MT5 financial accounts (#9314)

* chore: Dynamic leverage for MT5 financial accounts initial commit

* feat: 🚧 dynamic leverage modal

* test: unit tests

* feat: ✅ added unit tests and refactoring

* feat: ♻️ fixed UI

* feat: ♻️ review changes for dynamic leverage

* chore: item name update

* feat: 🐛 passed string to localize instead of a variable

* test: ♻️

* refactor: ♻️ refactored column header to new component

* refactor: refactored code

* fix: fixed styling and refactored code

* style: formatted code

* test: updated test mock component

* refactor: refactored styling and unit tests

* fix: fixed text content for dynamic leverage

* fix: fixed localize component usage

* refactor: used strong instead of span styling

* fix: jurisdiction card layout

---------

Co-authored-by: arshad-rao-deriv <muhammad.arshad@deriv.com>
Co-authored-by: mahdiyeh-deriv <82078941+mahdiyeh-deriv@users.noreply.github.com>

* translations: 📚 sync translations with crowdin (#9924)

Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>

* translations: 📚 sync translations with crowdin (#9925)

Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>

* fix: removed unecessary comments

* fix: removed unecessary comments

* fix: removed unecessary comments got added by eslint

* fix: removed unecessary comments got added by eslint

* fix: remove comments added while commiting

---------

Co-authored-by: Farzin Mirzaie <72082844+farzin-deriv@users.noreply.github.com>
Co-authored-by: Farzin Mirzaie <farzin@deriv.com>
Co-authored-by: Nijil Nirmal <nijil@deriv.com>
Co-authored-by: Farhan Ahmad Nurzi <125247833+farhan-nurzi-deriv@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>
Co-authored-by: Ali(Ako) Hosseini <ali.hosseini@deriv.com>
Co-authored-by: adrienne-rio <adrienne@deriv.com>
Co-authored-by: Sergei Baranovski <120570511+sergei-deriv@users.noreply.github.com>
Co-authored-by: adrienne-deriv <103016120+adrienne-deriv@users.noreply.github.com>
Co-authored-by: Shafin Al Karim <129021108+shafin-deriv@users.noreply.github.com>
Co-authored-by: Farabi <102643568+farabi-deriv@users.noreply.github.com>
Co-authored-by: Arshad Rao <135801848+arshad-rao-deriv@users.noreply.github.com>
Co-authored-by: Hamid <hamid@regentmarkets.com>
Co-authored-by: kate-deriv <121025168+kate-deriv@users.noreply.github.com>
Co-authored-by: Likhith Kolayari <98398322+likhith-deriv@users.noreply.github.com>
Co-authored-by: thisyahlen <104053934+thisyahlen-deriv@users.noreply.github.com>
Co-authored-by: henry-deriv <118344354+henry-deriv@users.noreply.github.com>
Co-authored-by: Maryia <103177211+maryia-deriv@users.noreply.github.com>
Co-authored-by: ameerul-deriv <103412909+ameerul-deriv@users.noreply.github.com>
Co-authored-by: George Usynin <103181646+heorhi-deriv@users.noreply.github.com>
Co-authored-by: hirad-deriv <hirad@re-work.dev>
Co-authored-by: hamza-deriv <hamza.muhammad@regentmarkets.com>
Co-authored-by: shontzu-deriv <shon.tzu@regentmarkets.com>
Co-authored-by: shontzu <108507236+shontzu-deriv@users.noreply.github.com>
Co-authored-by: Muhammad Hamza <120543468+hamza-deriv@users.noreply.github.com>
Co-authored-by: Matin shafiei <matin@deriv.com>
Co-authored-by: arshad-rao-deriv <muhammad.arshad@deriv.com>
Co-authored-by: mahdiyeh-deriv <82078941+mahdiyeh-deriv@users.noreply.github.com>
  • Loading branch information
1 parent 118e4e0 commit 68bacf3
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 62 deletions.
7 changes: 4 additions & 3 deletions packages/bot-web-ui/src/app/app.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import '../public-path'; // Leave this here (at the top)! OK boss!
import '../public-path';
import React from 'react';
import type { TRootStore, TWebSocket } from 'Types';
import { TStores } from '@deriv/stores/types';
import type { TWebSocket } from 'Types';
import AppContent from './app-content';
import DBotProviders from './dbot-providers';

type TAppProps = {
passthrough: {
WS: TWebSocket;
root_store: TRootStore;
root_store: TStores;
};
};

Expand Down
5 changes: 3 additions & 2 deletions packages/bot-web-ui/src/app/dbot-providers.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';
import { StoreProvider } from '@deriv/stores';
import type { TRootStore, TWebSocket } from 'Types';
import { TStores } from '@deriv/stores/types';
import type { TWebSocket } from 'Types';
import { DBotStoreProvider } from 'Stores/useDBotStore';

const DBotProviders = ({ children, store, WS }: React.PropsWithChildren<{ store: TRootStore; WS: TWebSocket }>) => {
const DBotProviders = ({ children, store, WS }: React.PropsWithChildren<{ store: TStores; WS: TWebSocket }>) => {
return (
<StoreProvider store={store}>
<DBotStoreProvider ws={WS}>{children}</DBotStoreProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const Toolbox = observer(() => {
/>
<div className='db-toolbox__category-menu'>
{toolbox_dom &&
(Array.from(toolbox_dom.childNodes) as HTMLElement[]).map((category, index) => {
Array.from(toolbox_dom.childNodes as HTMLElement[]).map((category, index) => {
if (category.tagName.toUpperCase() === 'CATEGORY') {
const has_sub_category = hasSubCategory(category.children);
const is_sub_category_open = sub_category_index.includes(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,18 @@ export type TInputUniqFields = 'input_martingale_size' | 'input_alembert_unit' |
export type TInputBaseFields = 'input_duration_value' | 'input_stake' | 'input_loss' | 'input_profit';
export type TInputCommonFields = TInputBaseFields | TInputUniqFields;

export type TSetFieldValue = (
element: 'button' | 'quick-strategy__duration-unit' | 'quick-strategy__duration-value' | string,
action: 'run' | 'edit' | string | number
) => void;

export type TSelectsFieldNames =
| 'quick-strategy__type-strategy'
| 'quick-strategy__symbol'
| 'quick-strategy__trade-type'
| 'quick-strategy__duration-unit'
| '';

export type TSetFieldValue = (
element: 'button' | 'quick-strategy__duration-unit' | 'quick-strategy__duration-value' | TSelectsFieldNames,
action: string | number
) => void;

export type TInputsFieldNames =
| 'quick-strategy__duration-value'
| 'quick-strategy__stake'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import { MobileWrapper, Toast } from '@deriv/components';
import { observer, useStore } from '@deriv/stores';
Expand Down
38 changes: 17 additions & 21 deletions packages/bot-web-ui/src/stores/load-modal-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default class LoadModalStore implements ILoadModalStore {

get selected_strategy(): TStrategy {
return (
this.dashboard_strategies.find((ws: { id: string }) => ws.id === this.selected_strategy_id) ||
this.dashboard_strategies.find((ws: { id: string }) => ws.id === this.selected_strategy_id) ??
this.dashboard_strategies[0]
);
}
Expand Down Expand Up @@ -290,16 +290,13 @@ export default class LoadModalStore implements ILoadModalStore {
onActiveIndexChange = (): void => {
if (this.tab_name === tabs_title.TAB_RECENT) {
this.previewRecentStrategy(this.selected_strategy_id);
} else {
// eslint-disable-next-line no-lonely-if
if (this.recent_workspace) {
setTimeout(() => {
// Dispose of recent workspace when switching away from Recent tab.
// Process in next cycle so user doesn't have to wait.
this.recent_workspace?.dispose();
this.recent_workspace = null;
});
}
} else if (this.recent_workspace) {
setTimeout(() => {
// Dispose of recent workspace when switching away from Recent tab.
// Process in next cycle so user doesn't have to wait.
this.recent_workspace?.dispose();
this.recent_workspace = null;
});
}

if (this.tab_name === tabs_title.TAB_LOCAL) {
Expand All @@ -310,16 +307,15 @@ export default class LoadModalStore implements ILoadModalStore {
this.drop_zone.addEventListener('drop', event => this.handleFileChange(event, false));
}
}
} else {
// Dispose of local workspace when switching away from Local tab.
// eslint-disable-next-line no-lonely-if
if (this.local_workspace) {
setTimeout(() => {
this.local_workspace?.dispose();
this.local_workspace = null;
this.setLoadedLocalFile(null);
}, 0);
}
}

// Dispose of local workspace when switching away from Local tab.
else if (this.local_workspace) {
setTimeout(() => {
this.local_workspace?.dispose();
this.local_workspace = null;
this.setLoadedLocalFile(null);
}, 0);
}

// Forget about drop zone when not on Local tab.
Expand Down
24 changes: 12 additions & 12 deletions packages/bot-web-ui/src/stores/quick-strategy-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ export default class QuickStrategyStore {
selected_trade_type: TTradeType = (this.qs_cache.selected_trade_type as TTradeType) || {};
selected_type_strategy: TTypeStrategy = (this.qs_cache.selected_type_strategy as TTypeStrategy) || {};
selected_duration_unit: TDurationOptions = (this.qs_cache.selected_duration_unit as TDurationOptions) || {};
input_duration_value: string | number = this.qs_cache.input_duration_value || '';
input_stake: string = this.qs_cache.input_stake || '';
input_martingale_size: string = this.qs_cache.input_martingale_size || '';
input_alembert_unit: string = this.qs_cache.input_alembert_unit || '';
input_oscar_unit: string = this.qs_cache.input_oscar_unit || '';
input_loss: string = this.qs_cache.input_loss || '';
input_profit: string = this.qs_cache.input_profit || '';
active_index: number = this.selected_type_strategy.index || 0;
description: string = this.qs_cache.selected_type_strategy?.description || '';
input_duration_value: string | number = this.qs_cache.input_duration_value ?? '';
input_stake: string = this.qs_cache.input_stake ?? '';
input_martingale_size: string = this.qs_cache.input_martingale_size ?? '';
input_alembert_unit: string = this.qs_cache.input_alembert_unit ?? '';
input_oscar_unit: string = this.qs_cache.input_oscar_unit ?? '';
input_loss: string = this.qs_cache.input_loss ?? '';
input_profit: string = this.qs_cache.input_profit ?? '';
active_index: number = this.selected_type_strategy.index ?? 0;
description: string = this.qs_cache.selected_type_strategy?.description ?? '';
types_strategies_dropdown: TTypeStrategiesDropdown = [];
symbol_dropdown: TSymbolDropdown = [];
trade_type_dropdown: TTradeTypeDropdown = [];
Expand Down Expand Up @@ -139,7 +139,7 @@ export default class QuickStrategyStore {

setDescription(type_strategy: TTypeStrategy): void {
this.description =
this.types_strategies_dropdown?.find(strategy => strategy.value === type_strategy.value)?.description || '';
this.types_strategies_dropdown?.find(strategy => strategy.value === type_strategy.value)?.description ?? '';
}

setDurationUnitDropdown(duration_unit_options: TDurationUnitDropdown): void {
Expand Down Expand Up @@ -485,7 +485,7 @@ export default class QuickStrategyStore {
let first_duration_unit: TDurationOptions = duration_options[0];
if (this.selected_duration_unit && duration_options?.some(e => e.value === this.selected_duration_unit.value)) {
first_duration_unit =
duration_options?.find(e => e.value === this.selected_duration_unit.value) ||
duration_options?.find(e => e.value === this.selected_duration_unit.value) ??
this.selected_duration_unit;
runInAction(() => {
first_duration_unit.text = this.getFieldValue(duration_options, this.selected_duration_unit.value);
Expand All @@ -496,7 +496,7 @@ export default class QuickStrategyStore {
if (first_duration_unit) {
this.setSelectedDurationUnit(first_duration_unit);
this.updateDurationValue(
this.qs_cache?.selected_duration_unit?.value || this.selected_duration_unit.value,
this.qs_cache?.selected_duration_unit?.value ?? this.selected_duration_unit.value,
setFieldValue
);

Expand Down
5 changes: 3 additions & 2 deletions packages/bot-web-ui/src/stores/root-store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { TDbot, TRootStore, TWebSocket } from 'Types';
import { TStores } from '@deriv/stores/types';
import type { TDbot, TWebSocket } from 'Types';
import AppStore from './app-store';
import BlocklyStore from './blockly-store';
import ChartStore from './chart-store';
Expand Down Expand Up @@ -48,7 +49,7 @@ export default class RootStore {
public blockly_store: BlocklyStore;
public data_collection_store: DataCollectionStore;

constructor(core: TRootStore, ws: TWebSocket, dbot: TDbot) {
constructor(core: TStores, ws: TWebSocket, dbot: TDbot) {
this.ws = ws;
this.dbot = dbot;
this.app = new AppStore(this, core);
Expand Down
2 changes: 1 addition & 1 deletion packages/bot-web-ui/src/stores/save-modal-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export default class SaveModalStore implements ISaveModalStore {
this.updateBotName(bot_name);

if (active_tab === 0) {
const workspace_id = selected_strategy.id || Blockly?.utils?.genUid();
const workspace_id = selected_strategy.id ?? Blockly?.utils?.genUid();
await this.addStrategyToWorkspace(workspace_id, is_local, save_as_collection, bot_name, xml);
if (main_strategy) await loadStrategyToBuilder(main_strategy);
} else {
Expand Down
9 changes: 0 additions & 9 deletions packages/bot-web-ui/src/types/root-stores.types.ts

This file was deleted.

10 changes: 5 additions & 5 deletions packages/hooks/src/__tests__/useCFDAllAccounts.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('useCFDAllAccounts', () => {
);
const { result } = renderHook(() => useCFDAllAccounts(), { wrapper });

expect(result.current.length).toBe(0);
expect(result.current).toHaveLength(0);
});

test('should return proper data when client has MT5 accounts', async () => {
Expand All @@ -33,7 +33,7 @@ describe('useCFDAllAccounts', () => {
);
const { result } = renderHook(() => useCFDAllAccounts(), { wrapper });

expect(result.current.length).toBe(1);
expect(result.current).toHaveLength(1);
});

test('should return proper data when client has dxtrade accounts', async () => {
Expand All @@ -54,7 +54,7 @@ describe('useCFDAllAccounts', () => {
);
const { result } = renderHook(() => useCFDAllAccounts(), { wrapper });

expect(result.current.length).toBe(1);
expect(result.current).toHaveLength(1);
});

test('should return proper data when client has ctrader accounts', async () => {
Expand All @@ -75,7 +75,7 @@ describe('useCFDAllAccounts', () => {
);
const { result } = renderHook(() => useCFDAllAccounts(), { wrapper });

expect(result.current.length).toBe(1);
expect(result.current).toHaveLength(1);
});

test('should return proper data when client has MT5, ctrader and dxtrade accounts', async () => {
Expand Down Expand Up @@ -110,6 +110,6 @@ describe('useCFDAllAccounts', () => {
);
const { result } = renderHook(() => useCFDAllAccounts(), { wrapper });

expect(result.current.length).toBe(3);
expect(result.current).toHaveLength(3);
});
});
15 changes: 15 additions & 0 deletions packages/stores/src/mockStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,21 @@ const mock = (): TStores & { is_mock: boolean } => {
update: jest.fn(),
unmount: jest.fn(),
},
gtm: {
is_gtm_applicable: false,
visitorId: 'visitorId',
common_variables: {
language: 'en',
theme: 'dark',
platform: 'DBot',
loggedIn: false,
},
accountSwitcherListener: jest.fn(),
pushDataLayer: jest.fn(),
pushTransactionData: jest.fn(),
eventHandler: jest.fn(),
setLoginFlag: jest.fn(),
},
};
};

Expand Down
22 changes: 22 additions & 0 deletions packages/stores/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {
SetFinancialAssessmentRequest,
SetFinancialAssessmentResponse,
StatesList,
Transaction,
} from '@deriv/api-types';
import type { Moment } from 'moment';
import type { RouteComponentProps } from 'react-router';
Expand Down Expand Up @@ -645,6 +646,26 @@ type TTradersHubStore = {
showTopUpModal: () => void;
};

type TGtmStore = {
is_gtm_applicable: boolean;
visitorId: Readonly<string>;
common_variables: Readonly<{
language: string;
visitorId?: string;
currency?: string;
userId?: string;
email?: string;
loggedIn: boolean;
theme: 'dark' | 'light';
platform: 'DBot' | 'MT5' | 'DTrader' | 'undefined';
}>;
accountSwitcherListener: () => Promise<Record<string, unknown>>;
pushDataLayer: (data: Record<string, unknown>) => void;
pushTransactionData: (response: Transaction, extra_data: Record<string, unknown>) => void;
eventHandler: (get_settings: GetSettings) => void;
setLoginFlag: (event_name: string) => void;
};

/**
* This is the type that contains all the `core` package stores
*/
Expand All @@ -660,6 +681,7 @@ export type TCoreStores = {
modules: Record<string, any>;
notifications: TNotificationStore;
traders_hub: TTradersHubStore;
gtm: TGtmStore;
};

export type TStores = TCoreStores & {
Expand Down

0 comments on commit 68bacf3

Please sign in to comment.