<>
- {content.map((content_data, index) => {
+ {content.map(content_data => {
return has_localize_component ? (
content_data
) : (
diff --git a/src/pages/tutorials/dbot-tours/onboarding-tour/index.tsx b/src/pages/tutorials/dbot-tours/onboarding-tour/index.tsx
index 799a52a8..aee2d6b8 100644
--- a/src/pages/tutorials/dbot-tours/onboarding-tour/index.tsx
+++ b/src/pages/tutorials/dbot-tours/onboarding-tour/index.tsx
@@ -1,5 +1,6 @@
import React from 'react';
import { observer } from 'mobx-react-lite';
+
import OnboardingTourDesktop from './onboarding-tour-desktop';
import OnboardingTourMobile from './onboarding-tour-mobile';
diff --git a/src/pages/tutorials/dbot-tours/tour-content.tsx b/src/pages/tutorials/dbot-tours/tour-content.tsx
index 7ecdeca9..87882397 100644
--- a/src/pages/tutorials/dbot-tours/tour-content.tsx
+++ b/src/pages/tutorials/dbot-tours/tour-content.tsx
@@ -3,7 +3,7 @@ import React from 'react';
import { Text } from '@deriv-com/ui';
import { isDbotRTL } from '@/external/bot-skeleton/utils/workspace';
-import { Localize, localize } from '@/utils/tmp/dummy';
+import { Icon, Localize, localize } from '@/utils/tmp/dummy';
import { getImageLocation, getUrlBase } from '../../../public-path';
diff --git a/src/pages/tutorials/faq-content/index.tsx b/src/pages/tutorials/faq-content/index.tsx
index 79818f83..1398ceac 100644
--- a/src/pages/tutorials/faq-content/index.tsx
+++ b/src/pages/tutorials/faq-content/index.tsx
@@ -4,7 +4,7 @@ import { Accordion, Text } from '@deriv-com/ui';
import { DBOT_TABS } from '@/constants/bot-contents';
import { useStore } from '@/hooks/useStore';
-import { localize } from '@/utils/tmp/dummy';
+import { Localize } from '@/utils/tmp/dummy';
import { TDescription } from '../tutorials.types';
@@ -25,7 +25,7 @@ const FAQ = ({ type, content = '', src, imageclass, is_mobile }: TDescription) =
return (
{
className='faq__title'
weight='bold'
key={title}
- size={is_mobile ? 'xs' : 's'}
+ size={is_mobile ? 'xs' : 'sm'}
>
{title}
@@ -127,7 +127,7 @@ const FAQContent = ({ faq_list, handleTabChange }: TFAQContent) => {
line_height='xl'
className='faq__wrapper__header'
weight='bold'
- size={is_mobile ? 'xs' : 's'}
+ size={is_mobile ? 'xs' : 'sm'}
>
diff --git a/src/pages/tutorials/index.ts b/src/pages/tutorials/index.ts
index 2890b5b5..039810c1 100644
--- a/src/pages/tutorials/index.ts
+++ b/src/pages/tutorials/index.ts
@@ -1,4 +1,5 @@
import TutorialTab from './tutorials';
+
import './tutorials.scss';
export default TutorialTab;
diff --git a/src/pages/tutorials/quick-strategy-content/quick-strategy-guides-details.tsx b/src/pages/tutorials/quick-strategy-content/quick-strategy-guides-details.tsx
index cee49e27..c532b804 100644
--- a/src/pages/tutorials/quick-strategy-content/quick-strategy-guides-details.tsx
+++ b/src/pages/tutorials/quick-strategy-content/quick-strategy-guides-details.tsx
@@ -5,7 +5,7 @@ import { Text } from '@deriv-com/ui';
import { isDbotRTL } from '@/external/bot-skeleton/utils/workspace';
import { useStore } from '@/hooks/useStore';
-import { Icon, localize } from '@/utils/tmp/dummy';
+import { Icon, Localize } from '@/utils/tmp/dummy';
import { STRATEGIES } from '../../bot-builder/quick-strategy/config';
import StrategyTabContent from '../../bot-builder/quick-strategy/form-wrappers/strategy-tab-content';
@@ -26,7 +26,7 @@ const QuickStrategyGuidesDetail = observer(
({ quick_strategy_tab_content, tutorial_selected_strategy, setTutorialSelectedStrategy }: TQuickStrategyGuides) => {
const { ui } = useStore();
const { is_mobile } = ui;
- const text_size = is_mobile ? 'xs' : 's';
+ const text_size = is_mobile ? 'xs' : 'sm';
return (
<>
diff --git a/src/stores/app-store.ts b/src/stores/app-store.ts
index 6bf7ae4f..fbc37896 100644
--- a/src/stores/app-store.ts
+++ b/src/stores/app-store.ts
@@ -14,8 +14,6 @@ import {
import RootStore from './root-store';
-const Blockly = window.Blockly;
-
export default class AppStore {
root_store: RootStore;
core: TStores;
@@ -177,8 +175,8 @@ export default class AppStore {
DBot.terminateBot();
DBot.terminateConnection();
if (window.Blockly?.derivWorkspace) {
- clearInterval(window.Blockly.derivWorkspace.save_workspace_interval);
- window.Blockly.derivWorkspace.dispose();
+ clearInterval(window.Blockly?.derivWorkspace.save_workspace_interval);
+ window.Blockly.derivWorkspace?.dispose();
}
if (typeof this.disposeReloadOnLanguageChangeReaction === 'function') {
this.disposeReloadOnLanguageChangeReaction();
@@ -201,7 +199,7 @@ export default class AppStore {
// Ensure account switch is re-enabled.
// TODO: fix
- const { ui } = this.core;
+ // const { ui } = this.core;
// ui.setAccountSwitcherDisabledMessage();
// ui.setPromptHandler(false);
@@ -237,9 +235,9 @@ export default class AppStore {
this.disposeCurrencyReaction = reaction(
() => this.core.client.currency,
currency => {
- if (!Blockly.derivWorkspace) return;
+ if (!window.Blockly?.derivWorkspace) return;
- const trade_options_blocks = Blockly.derivWorkspace
+ const trade_options_blocks = window.Blockly?.derivWorkspace
.getAllBlocks()
.filter(
b =>
@@ -265,16 +263,16 @@ export default class AppStore {
if (ApiHelpers.instance) {
const { active_symbols, contracts_for } = ApiHelpers.instance;
- if (Blockly.derivWorkspace) {
+ if (window.Blockly?.derivWorkspace) {
active_symbols.retrieveActiveSymbols(true).then(() => {
contracts_for.disposeCache();
- Blockly.derivWorkspace
+ window.Blockly?.derivWorkspace
.getAllBlocks()
.filter(block => block.type === 'trade_definition_market')
- .forEach(block => {
+ .forEach(() => {
runIrreversibleEvents(() => {
- const fake_create_event = new Blockly.Events.BlockCreate(this);
- Blockly.Events.fire(fake_create_event);
+ const fake_create_event = new window.Blockly.Events.BlockCreate(this);
+ window.Blockly.Events.fire(fake_create_event);
});
});
});
diff --git a/src/stores/blockly-store.ts b/src/stores/blockly-store.ts
index a24d8950..02c7c4cb 100644
--- a/src/stores/blockly-store.ts
+++ b/src/stores/blockly-store.ts
@@ -1,7 +1,9 @@
import { action, makeObservable, observable } from 'mobx';
-import { onWorkspaceResize } from '@/external/bot-skeleton';
+
import { tabs_title } from '@/constants/bot-contents';
+import { onWorkspaceResize } from '@/external/bot-skeleton';
import { getSetting, storeSetting } from '@/utils/settings';
+
import RootStore from './root-store';
export default class BlocklyStore {
diff --git a/src/stores/chart-store.ts b/src/stores/chart-store.ts
index 86ed9233..1b918864 100644
--- a/src/stores/chart-store.ts
+++ b/src/stores/chart-store.ts
@@ -8,8 +8,8 @@ import {
TradingTimesRequest,
} from '@deriv/api-types';
+import { LocalStore } from '@/components/shared';
import { ServerTime } from '@/external/bot-skeleton';
-import { LocalStore } from '@/utils/tmp/local-storage-helper';
import RootStore from './root-store';
@@ -130,7 +130,7 @@ export default class ChartStore {
wsSubscribe = (req: TicksStreamRequest, callback: () => void) => {
if (req.subscribe === 1) {
const key = JSON.stringify(req);
- const subscriber = WS.subscribeTicksHistory(req, callback);
+ const subscriber = WS?.subscribeTicksHistory(req, callback);
g_subscribers_map[key] = subscriber;
}
};
@@ -144,7 +144,7 @@ export default class ChartStore {
};
wsForgetStream = (stream_id: string) => {
- WS.forgetStream(stream_id);
+ WS?.forgetStream(stream_id);
};
wsSendRequest = (req: TradingTimesRequest | ActiveSymbolsRequest | ServerTimeRequest) => {
@@ -157,9 +157,9 @@ export default class ChartStore {
});
}
if ('active_symbols' in req && req.active_symbols) {
- return WS.activeSymbols();
+ return WS?.activeSymbols();
}
- if (WS.storage.send) return WS.storage.send(req);
+ if (WS?.storage.send) return WS?.storage.send(req);
};
getMarketsOrder = (active_symbols: { market: string; display_name: string }[]) => {
diff --git a/src/stores/data-collection-store.ts b/src/stores/data-collection-store.ts
index 23a601e7..a41ff071 100644
--- a/src/stores/data-collection-store.ts
+++ b/src/stores/data-collection-store.ts
@@ -3,9 +3,9 @@ import { action, makeObservable, observable, reaction } from 'mobx';
import { TStores } from '@deriv/stores/types';
+import { cloneObject } from '@/components/shared';
import { DBot } from '@/external/bot-skeleton';
import { isProduction } from '@/utils/tmp/dummy';
-import { cloneObject } from '@/utils/tmp/object-helper';
import RootStore from './root-store';
diff --git a/src/stores/journal-store.ts b/src/stores/journal-store.ts
index 01a2c430..61014d0a 100644
--- a/src/stores/journal-store.ts
+++ b/src/stores/journal-store.ts
@@ -3,10 +3,10 @@ import { v4 as uuidv4 } from 'uuid';
import { TStores } from '@deriv/stores/types';
+import { formatDate } from '@/components/shared';
import { LogTypes, MessageTypes } from '@/external/bot-skeleton';
import { config } from '@/external/bot-skeleton/constants/config';
import { localize } from '@/utils/tmp/dummy';
-import { formatDate } from '@/utils/tmp/time-helper';
import { isCustomJournalMessage } from '../utils/journal-notifications';
import { getStoredItemsByKey, getStoredItemsByUser, setStoredItemsByKey } from '../utils/session-storage';
diff --git a/src/stores/route-prompt-dialog-store.ts b/src/stores/route-prompt-dialog-store.ts
index 5e050774..c6234bd7 100644
--- a/src/stores/route-prompt-dialog-store.ts
+++ b/src/stores/route-prompt-dialog-store.ts
@@ -1,5 +1,7 @@
import { action, makeObservable, observable } from 'mobx';
+
import { TStores } from '@deriv/stores/types';
+
import RootStore from './root-store';
export interface IRoutePromptDialogStore {
diff --git a/src/stores/run-panel-store.ts b/src/stores/run-panel-store.ts
index 6f34dd16..cadc67ff 100644
--- a/src/stores/run-panel-store.ts
+++ b/src/stores/run-panel-store.ts
@@ -7,6 +7,7 @@ import { TDbot } from 'Types';
import { botNotification } from '@/components/bot-notification/bot-notification';
import { notification_message } from '@/components/bot-notification/bot-notification-utils';
+import { isSafari, mobileOSDetect } from '@/components/shared';
import { contract_stages, TContractStage } from '@/constants/contract-stage';
import { run_panel } from '@/constants/run-panel';
import { ErrorTypes, MessageTypes, observer, unrecoverable_errors } from '@/external/bot-skeleton';
@@ -14,7 +15,6 @@ import { journalError, switch_account_notification } from '@/utils/bot-notificat
import GTM from '@/utils/gtm';
import { helpers } from '@/utils/store-helpers';
import { localize, routes } from '@/utils/tmp/dummy';
-import { isSafari, mobileOSDetect } from '@/utils/tmp/os-detect';
import RootStore from './root-store';
diff --git a/src/stores/save-modal-store.ts b/src/stores/save-modal-store.ts
index fde5bae2..4f5ebe4b 100644
--- a/src/stores/save-modal-store.ts
+++ b/src/stores/save-modal-store.ts
@@ -1,6 +1,11 @@
import localForage from 'localforage';
import LZString from 'lz-string';
import { action, makeObservable, observable } from 'mobx';
+
+import { TStrategy } from 'Types';
+
+import { MAX_STRATEGIES } from '@/constants/bot-contents';
+import { button_status } from '@/constants/button-status';
import {
getSavedWorkspaces,
observer as globalObserver,
@@ -9,9 +14,7 @@ import {
saveWorkspaceToRecent,
} from '@/external/bot-skeleton';
import { localize } from '@/utils/tmp/dummy';
-import { MAX_STRATEGIES } from '@/constants/bot-contents';
-import { button_status } from '@/constants/button-status';
-import { TStrategy } from 'Types';
+
import RootStore from './root-store';
type IOnConfirmProps = {
diff --git a/src/stores/self-exclusion-store.ts b/src/stores/self-exclusion-store.ts
index ed0bfb38..820fe598 100644
--- a/src/stores/self-exclusion-store.ts
+++ b/src/stores/self-exclusion-store.ts
@@ -1,5 +1,7 @@
import { action, computed, makeObservable, observable } from 'mobx';
+
import { TStores } from '@deriv/stores/types';
+
import RootStore from './root-store';
export default class SelfExclusionStore {
diff --git a/src/stores/summary-card-store.ts b/src/stores/summary-card-store.ts
index 46c6a540..f8a7d390 100644
--- a/src/stores/summary-card-store.ts
+++ b/src/stores/summary-card-store.ts
@@ -3,12 +3,11 @@ import { action, computed, makeObservable, observable, reaction } from 'mobx';
import { ProposalOpenContract, UpdateContractResponse } from '@deriv/api-types';
import { TStores } from '@deriv/stores/types';
+import { getIndicativePrice, isEqualObject, isMultiplierContract } from '@/components/shared';
import { TContractInfo } from '@/components/summary/summary-card.types';
import { getValidationRules, TValidationRuleIndex, TValidationRules } from '@/constants/contract';
import { contract_stages } from '@/constants/contract-stage';
import { getContractUpdateConfig } from '@/utils/multiplier';
-import { getIndicativePrice, isMultiplierContract } from '@/utils/tmp/contract-helper';
-import { isEqualObject } from '@/utils/tmp/object-helper';
import Validator from '@/utils/tmp/validator';
import RootStore from './root-store';
diff --git a/src/stores/toolbar-store.ts b/src/stores/toolbar-store.ts
index 33b0ff18..c76fde6a 100644
--- a/src/stores/toolbar-store.ts
+++ b/src/stores/toolbar-store.ts
@@ -1,5 +1,7 @@
import { action, makeObservable, observable } from 'mobx';
+
import { config, load, runGroupedEvents } from '@/external/bot-skeleton';
+
import RootStore from './root-store';
interface IToolbarStore {
diff --git a/src/stores/toolbox-store.ts b/src/stores/toolbox-store.ts
index 10e69463..54ded1b0 100644
--- a/src/stores/toolbox-store.ts
+++ b/src/stores/toolbox-store.ts
@@ -1,7 +1,10 @@
import { action, makeObservable, observable, reaction } from 'mobx';
-import { scrollWorkspace } from '@/external/bot-skeleton';
+
import { TStores } from '@deriv/stores/types';
+
+import { scrollWorkspace } from '@/external/bot-skeleton';
import { localize } from '@/utils/tmp/dummy';
+
import RootStore from './root-store';
export default class ToolboxStore {
diff --git a/src/stores/transactions-store.ts b/src/stores/transactions-store.ts
index f682352b..b1bdbdaa 100644
--- a/src/stores/transactions-store.ts
+++ b/src/stores/transactions-store.ts
@@ -3,10 +3,8 @@ import { action, computed, makeObservable, observable, reaction } from 'mobx';
import { ProposalOpenContract } from '@deriv/api-types';
import { TPortfolioPosition, TStores } from '@deriv/stores/types';
-// import { formatDate, isEnded } from '@deriv-com/utils';
+import { formatDate, isEnded } from '@/components/shared';
import { LogTypes } from '@/external/bot-skeleton';
-import { isEnded } from '@/utils/tmp/contract-helper';
-import { formatDate } from '@/utils/tmp/time-helper';
import { TContractInfo } from '../components/summary/summary-card.types';
import { transaction_elements } from '../constants/transactions';
diff --git a/src/types/stores.types.ts b/src/types/stores.types.ts
index 6b98e622..8d7f78d7 100644
--- a/src/types/stores.types.ts
+++ b/src/types/stores.types.ts
@@ -1,10 +1,12 @@
import { TStores } from '@deriv/stores/types';
+
import DashboardStore from 'Stores/dashboard-store';
import FlyoutStore from 'Stores/flyout-store';
import LoadModalStore from 'Stores/load-modal-store';
import RunPanelStore from 'Stores/run-panel-store';
import SaveModalStore from 'Stores/save-modal-store';
import ToolbarStore from 'Stores/toolbar-store';
+
import { TWebSocket } from './ws.types';
export type TDbotStore = {
diff --git a/src/utils/dom-observer.ts b/src/utils/dom-observer.ts
index fedd5c11..622b6bdf 100644
--- a/src/utils/dom-observer.ts
+++ b/src/utils/dom-observer.ts
@@ -1,7 +1,8 @@
export const waitForDomElement = (selector: string, observingParent?: Element) => {
return new Promise(resolve => {
if (document.querySelector(selector)) {
- return resolve(document.querySelector(selector));
+ resolve(document.querySelector(selector));
+ return;
}
const observer = new MutationObserver(() => {
diff --git a/src/utils/gtm.ts b/src/utils/gtm.ts
index 3ded0d6b..d2183603 100644
--- a/src/utils/gtm.ts
+++ b/src/utils/gtm.ts
@@ -1,9 +1,12 @@
import { reaction } from 'mobx';
+
import { ProposalOpenContract } from '@deriv/api-types';
import { TCoreStores, TStores } from '@deriv/stores/types';
-import { TStatistics } from '@/components/transaction-details/transaction-details.types';
+
import RootStore from 'Stores/root-store';
+import { TStatistics } from '@/components/transaction-details/transaction-details.types';
+
type TGTM = {
core: {
client: {
diff --git a/src/utils/journal-notifications.ts b/src/utils/journal-notifications.ts
index babd4209..c4b89c24 100644
--- a/src/utils/journal-notifications.ts
+++ b/src/utils/journal-notifications.ts
@@ -1,5 +1,5 @@
-import { localize } from '@/utils/tmp/dummy';
import { arrayAsMessage, messageWithButton } from '@/components/notify-item';
+import { localize } from '@/utils/tmp/dummy';
const showErrorMessageWithButton = (message, block_id, showErrorMessage, centerAndHighlightBlock) => {
showErrorMessage(
diff --git a/src/utils/multiplier.ts b/src/utils/multiplier.ts
index aabea520..5f587dc3 100644
--- a/src/utils/multiplier.ts
+++ b/src/utils/multiplier.ts
@@ -1,6 +1,6 @@
import { ContractUpdate, ProposalOpenContract } from '@deriv/api-types';
-import { getLimitOrderAmount } from './tmp/contract-helper';
+import { getLimitOrderAmount } from '@/components/shared';
type TContractUpdateConfig = (ContractUpdate & ProposalOpenContract['limit_order']) | undefined;
/**
diff --git a/src/utils/tmp/connection-helper.ts b/src/utils/tmp/connection-helper.ts
deleted file mode 100644
index 141a90b4..00000000
--- a/src/utils/tmp/connection-helper.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-export const getSocketURL = () => {
- const local_storage_server_url = window.localStorage.getItem('config.server_url');
- if (local_storage_server_url) return local_storage_server_url;
-
- let active_loginid_from_url;
- const search = window.location.search;
- if (search) {
- const params = new URLSearchParams(document.location.search.substring(1));
- active_loginid_from_url = params.get('acct1');
- }
-
- const loginid = window.localStorage.getItem('active_loginid') || active_loginid_from_url;
- const is_real = loginid && !/^(VRT|VRW)/.test(loginid);
-
- const server = is_real ? 'green' : 'blue';
- const server_url = `${server}.derivws.com`;
-
- return server_url;
-};
diff --git a/src/utils/tmp/contract-helper.ts b/src/utils/tmp/contract-helper.ts
deleted file mode 100644
index 097e5396..00000000
--- a/src/utils/tmp/contract-helper.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-export const isMultiplierContract = (contract_type = '') => /MULT/i.test(contract_type);
-
-export const isEnded = (contract_info: TContractInfo) =>
- !!(
- (contract_info.status && contract_info.status !== 'open') ||
- contract_info.is_expired ||
- contract_info.is_settleable
- );
-
-export const getTotalProfit = (contract_info: TContractInfo) =>
- Number(contract_info.bid_price) - Number(contract_info.buy_price);
-
-export const getLimitOrderAmount = (limit_order?: TLimitOrder) => {
- if (!limit_order) return { stop_loss: null, take_profit: null };
- const {
- stop_loss: { order_amount: stop_loss_order_amount } = {},
- take_profit: { order_amount: take_profit_order_amount } = {},
- } = limit_order;
-
- return {
- stop_loss: stop_loss_order_amount,
- take_profit: take_profit_order_amount,
- };
-};
-
-export const getFinalPrice = (contract_info: TContractInfo) => contract_info.sell_price || contract_info.bid_price;
-
-export const getIndicativePrice = (contract_info: TContractInfo) =>
- getFinalPrice(contract_info) && isEnded(contract_info)
- ? getFinalPrice(contract_info)
- : Number(contract_info.bid_price);
diff --git a/src/utils/tmp/currency-helper.ts b/src/utils/tmp/currency-helper.ts
deleted file mode 100644
index 22aacd38..00000000
--- a/src/utils/tmp/currency-helper.ts
+++ /dev/null
@@ -1,333 +0,0 @@
-import { deepFreeze, getPropertyValue } from './object-helper';
-
-export type TCurrenciesConfig = {
- [key: string]: {
- fractional_digits: number;
- is_deposit_suspended?: 0 | 1;
- is_suspended?: 0 | 1;
- is_withdrawal_suspended?: 0 | 1;
- name?: string;
- stake_default?: number;
- transfer_between_accounts?: {
- fees?: { [key: string]: number };
- limits: {
- max?: number;
- min: number;
- [key: string]: unknown;
- } | null;
- limits_dxtrade?: { [key: string]: unknown };
- limits_mt5?: { [key: string]: unknown };
- };
- type: string;
- };
-};
-
-let currencies_config: TCurrenciesConfig = {};
-
-const fiat_currencies_display_order = ['USD', 'EUR', 'GBP', 'AUD'];
-const crypto_currencies_display_order = [
- 'TUSDT',
- 'BTC',
- 'ETH',
- 'LTC',
- 'UST',
- 'eUSDT',
- 'BUSD',
- 'DAI',
- 'EURS',
- 'IDK',
- 'PAX',
- 'TUSD',
- 'USDC',
- 'USDK',
-];
-
-export const reorderCurrencies =
(
- list: Array,
- type = 'fiat'
-) => {
- const new_order = type === 'fiat' ? fiat_currencies_display_order : crypto_currencies_display_order;
-
- return list.sort((a, b) => {
- if (new_order.indexOf(a.value) < new_order.indexOf(b.value)) {
- return -1;
- }
- if (new_order.indexOf(a.value) > new_order.indexOf(b.value)) {
- return 1;
- }
- return 0;
- });
-};
-
-export const AMOUNT_MAX_LENGTH = 10;
-
-export const CURRENCY_TYPE = {
- CRYPTO: 'crypto',
- FIAT: 'fiat',
-} as const;
-
-export const getRoundedNumber = (number: number, currency: string) => {
- return Number(Number(number).toFixed(getDecimalPlaces(currency)));
-};
-
-export const getFormattedText = (number: number, currency: string) => {
- return `${addComma(number, getDecimalPlaces(currency), isCryptocurrency(currency))} ${currency}`;
-};
-
-/**
- * @deprecated Please use 'FormatUtils.formatMoney' from '@deriv-com/utils' instead of this.
- */
-export const formatMoney = (
- currency_value: string,
- amount: number | string,
- exclude_currency?: boolean,
- decimals = 0,
- minimumFractionDigits = 0
-) => {
- let money: number | string = amount;
- if (money) money = String(money).replace(/,/g, '');
- const sign = money && Number(money) < 0 ? '-' : '';
- const decimal_places = decimals || getDecimalPlaces(currency_value);
-
- money = isNaN(+money) ? 0 : Math.abs(+money);
- if (typeof Intl !== 'undefined') {
- const options = {
- minimumFractionDigits: minimumFractionDigits || decimal_places,
- maximumFractionDigits: decimal_places,
- };
- // TODO: [use-shared-i18n] - Use a getLanguage function to determine number format.
- money = new Intl.NumberFormat('en', options).format(money);
- } else {
- money = addComma(money, decimal_places);
- }
-
- return sign + (exclude_currency ? '' : formatCurrency(currency_value)) + money;
-};
-
-export const formatCurrency = (currency: string) => {
- return ``;
-};
-
-export const addComma = (num?: number | string | null, decimal_points?: number, is_crypto?: boolean) => {
- let number: number | string = String(num || 0).replace(/,/g, '');
- if (typeof decimal_points !== 'undefined') {
- number = (+number).toFixed(decimal_points);
- }
- if (is_crypto) {
- number = parseFloat(String(number));
- }
-
- return number
- .toString()
- .replace(/(^|[^\w.])(\d{4,})/g, ($0, $1, $2) => $1 + $2.replace(/\d(?=(?:\d\d\d)+(?!\d))/g, '$&,'));
-};
-
-export const calcDecimalPlaces = (currency: string) => {
- return isCryptocurrency(currency) ? getPropertyValue(CryptoConfig.get(), [currency, 'fractional_digits']) : 2;
-};
-
-export const getDecimalPlaces = (currency = '') =>
- // need to check currencies_config[currency] exists instead of || in case of 0 value
- currencies_config[currency]
- ? getPropertyValue(currencies_config, [currency, 'fractional_digits'])
- : calcDecimalPlaces(currency);
-
-export const setCurrencies = (website_status: { currencies_config: TCurrenciesConfig }) => {
- currencies_config = website_status.currencies_config;
-};
-
-// (currency in crypto_config) is a back-up in case website_status doesn't include the currency config, in some cases where it's disabled
-export const isCryptocurrency = (currency: string) => {
- return /crypto/i.test(getPropertyValue(currencies_config, [currency, 'type'])) || currency in CryptoConfig.get();
-};
-
-export const CryptoConfig = (() => {
- let crypto_config: unknown;
-
- // TODO: [use-shared-i18n] - Use translate function shared among apps or pass in translated names externally.
- const initCryptoConfig = () =>
- deepFreeze({
- BTC: {
- display_code: 'BTC',
- name: 'Bitcoin',
- min_withdrawal: 0.002,
- pa_max_withdrawal: 5,
- pa_min_withdrawal: 0.002,
- fractional_digits: 8,
- },
- BUSD: {
- display_code: 'BUSD',
- name: 'Binance USD',
- min_withdrawal: 0.002,
- pa_max_withdrawal: 5,
- pa_min_withdrawal: 0.002,
- fractional_digits: 2,
- },
- DAI: {
- display_code: 'DAI',
- name: 'Multi-Collateral DAI',
- min_withdrawal: 0.002,
- pa_max_withdrawal: 5,
- pa_min_withdrawal: 0.002,
- fractional_digits: 2,
- },
- EURS: {
- display_code: 'EURS',
- name: 'STATIS Euro',
- min_withdrawal: 0.002,
- pa_max_withdrawal: 5,
- pa_min_withdrawal: 0.002,
- fractional_digits: 2,
- },
- IDK: {
- display_code: 'IDK',
- name: 'IDK',
- min_withdrawal: 0.002,
- pa_max_withdrawal: 5,
- pa_min_withdrawal: 0.002,
- fractional_digits: 0,
- },
- PAX: {
- display_code: 'PAX',
- name: 'Paxos Standard',
- min_withdrawal: 0.002,
- pa_max_withdrawal: 5,
- pa_min_withdrawal: 0.002,
- fractional_digits: 2,
- },
- TUSD: {
- display_code: 'TUSD',
- name: 'True USD',
- min_withdrawal: 0.002,
- pa_max_withdrawal: 5,
- pa_min_withdrawal: 0.002,
- fractional_digits: 2,
- },
- USDC: {
- display_code: 'USDC',
- name: 'USD Coin',
- min_withdrawal: 0.002,
- pa_max_withdrawal: 5,
- pa_min_withdrawal: 0.002,
- fractional_digits: 2,
- },
- USDK: {
- display_code: 'USDK',
- name: 'USDK',
- min_withdrawal: 0.002,
- pa_max_withdrawal: 5,
- pa_min_withdrawal: 0.002,
- fractional_digits: 2,
- },
- eUSDT: {
- display_code: 'eUSDT',
- name: 'Tether ERC20',
- min_withdrawal: 0.002,
- pa_max_withdrawal: 5,
- pa_min_withdrawal: 0.002,
- fractional_digits: 2,
- },
- tUSDT: {
- display_code: 'tUSDT',
- name: 'Tether TRC20',
- min_withdrawal: 0.002,
- pa_max_withdrawal: 5,
- pa_min_withdrawal: 0.002,
- fractional_digits: 2,
- },
- BCH: {
- display_code: 'BCH',
- name: 'Bitcoin Cash',
- min_withdrawal: 0.002,
- pa_max_withdrawal: 5,
- pa_min_withdrawal: 0.002,
- fractional_digits: 8,
- },
- ETH: {
- display_code: 'ETH',
- name: 'Ether',
- min_withdrawal: 0.002,
- pa_max_withdrawal: 5,
- pa_min_withdrawal: 0.002,
- fractional_digits: 8,
- },
- ETC: {
- display_code: 'ETC',
- name: 'Ether Classic',
- min_withdrawal: 0.002,
- pa_max_withdrawal: 5,
- pa_min_withdrawal: 0.002,
- fractional_digits: 8,
- },
- LTC: {
- display_code: 'LTC',
- name: 'Litecoin',
- min_withdrawal: 0.002,
- pa_max_withdrawal: 5,
- pa_min_withdrawal: 0.002,
- fractional_digits: 8,
- },
- UST: {
- display_code: 'USDT',
- name: 'Tether Omni',
- min_withdrawal: 0.02,
- pa_max_withdrawal: 2000,
- pa_min_withdrawal: 10,
- fractional_digits: 2,
- },
- // USB: {
- // display_code: 'USB',
- // name: 'Binary Coin',
- // min_withdrawal: 0.02,
- // pa_max_withdrawal: 2000,
- // pa_min_withdrawal: 10,
- // fractional_digits: 2,
- // },
- });
-
- return {
- get: () => {
- if (!crypto_config) {
- crypto_config = initCryptoConfig();
- }
- return crypto_config;
- },
- };
-})();
-
-export const getMinWithdrawal = (currency: string) => {
- return isCryptocurrency(currency) ? getPropertyValue(CryptoConfig.get(), [currency, 'min_withdrawal']) || 0.002 : 1;
-};
-
-export const getTransferFee = (currency_from: string, currency_to: string) => {
- const transfer_fee = getPropertyValue(currencies_config, [
- currency_from,
- 'transfer_between_accounts',
- 'fees',
- currency_to,
- ]);
- return `${typeof transfer_fee === 'undefined' ? '1' : transfer_fee}%`;
-};
-
-export const getCurrencyDisplayCode = (currency = '') => {
- // eslint-disable-next-line
- if (currency !== 'eUSDT' && currency !== 'tUSDT') currency = currency.toUpperCase();
- return getPropertyValue(CryptoConfig.get(), [currency, 'display_code']) || currency;
-};
-
-export const getCurrencyName = (currency = '') =>
- currency === 'USDT' ? 'Tether Omni' : getPropertyValue(currencies_config, [currency, 'name']) || '';
-
-export const getMinPayout = (currency: string) => {
- return getPropertyValue(currencies_config, [currency, 'stake_default']);
-};
-
-export const getCurrencies = () => {
- return currencies_config;
-};
-
-export type TAccount = {
- account_type: 'real' | 'demo';
- balance: number;
- currency: string;
-};
diff --git a/src/utils/tmp/dummy.tsx b/src/utils/tmp/dummy.tsx
index 36f95f45..276b9400 100644
--- a/src/utils/tmp/dummy.tsx
+++ b/src/utils/tmp/dummy.tsx
@@ -1,6 +1,6 @@
export const localize = (str: unknown, obj: unknown = {}) => `${str} ${JSON.stringify(obj)}`;
-export const Localize = ({ i18n_default_text = '', values = {}, components = [], options = {} }) => {
+export const Localize = ({ i18n_default_text = '', values = {}, components = [] }) => {
// Simulate basic interpolation
const interpolatedText = i18n_default_text.replace(/\{\{([^}]+)\}\}/g, (match, key) => values[key] || '');
@@ -26,7 +26,7 @@ export const i18n = {
language: 'en',
};
-export const Icon = ({ icon, size = 16 }) => {
+export const Icon = ({ icon }) => {
// Simulate placeholder icon rendering
return {icon}
;
};
@@ -56,6 +56,7 @@ export const ContentFlag = Object.freeze({
export const routes = {
traders_hub: '/appstore/traders-hub',
reports: '/reports',
+ bot: '/bot',
};
// eu countries to support
diff --git a/src/utils/tmp/helper.js b/src/utils/tmp/helper.js
deleted file mode 100644
index 304dfef1..00000000
--- a/src/utils/tmp/helper.js
+++ /dev/null
@@ -1,36 +0,0 @@
-export const getKebabCase = str => {
- if (!str) return str;
- return str
- .replace(/([a-z0-9])([A-Z])/g, '$1-$2') // get all lowercase letters that are near to uppercase ones
- .replace(/[\s]+/g, '-') // replace all spaces and low dash
- .toLowerCase();
-};
-
-export const getPascalCase = str => {
- if (!str) return '';
- return (
- String(str)
- .replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '$')
- .replace(/[^_A-Za-z0-9]+/g, '$')
- .replace(/([a-z])([A-Z])/g, (m, a, b) => `${a}$${b}`)
- // .toLowerCase()
- .replace(/(\$)(\w?)/g, (m, a, b) => b.toUpperCase())
- );
-};
-
-export const getSnakeCase = str => {
- if (!str) return str;
- return str
- .replace(/([a-z0-9])([A-Z])/g, '$1_$2') // get all lowercase letters that are near to uppercase ones
- .replace(/[\s]+/g, '_') // replace all spaces and low dash
- .toLowerCase();
-};
-
-export const getFileNameFromPath = path => path.match(/([^/]*)\/*$/)[1].replace('.svg', '');
-
-export const getEnglishCharacters = input =>
- input
- .normalize('NFD')
- .split('')
- .filter(char => /^[a-z ]*$/i.test(char))
- .join('');
diff --git a/src/utils/tmp/local-storage-helper.ts b/src/utils/tmp/local-storage-helper.ts
deleted file mode 100644
index 0272ea63..00000000
--- a/src/utils/tmp/local-storage-helper.ts
+++ /dev/null
@@ -1,254 +0,0 @@
-import Cookies from 'js-cookie';
-
-import { deriv_urls } from './dummy';
-import { cloneObject } from './object-helper';
-
-type TCookieStorageThis = {
- initialized: boolean;
- cookie_name: string;
- domain: string;
- path: string;
- expires: Date;
- value: unknown;
-};
-
-const getObject = function (this: { getItem: (key: string) => string | null }, key: string) {
- return JSON.parse(this.getItem(key) || '{}');
-};
-
-const setObject = function (this: { setItem: (key: string, value: string) => void }, key: string, value: unknown) {
- if (value && value instanceof Object) {
- try {
- this.setItem(key, JSON.stringify(value));
- } catch (e) {
- /* do nothing */
- }
- }
-};
-
-if (typeof Storage !== 'undefined') {
- Storage.prototype.getObject = getObject;
- Storage.prototype.setObject = setObject;
-}
-
-export const isStorageSupported = (storage: Storage) => {
- if (typeof storage === 'undefined') {
- return false;
- }
-
- const test_key = 'test';
- try {
- storage.setItem(test_key, '1');
- storage.removeItem(test_key);
- return true;
- } catch (e) {
- return false;
- }
-};
-
-const Store = function (this: { storage: Storage }, storage: Storage) {
- this.storage = storage;
- this.storage.getObject = getObject;
- this.storage.setObject = setObject;
-};
-
-Store.prototype = {
- get(key: string) {
- return this.storage.getItem(key) || undefined;
- },
- set(key: string, value: string) {
- if (typeof value !== 'undefined') {
- this.storage.setItem(key, value);
- }
- },
- getObject(key: string) {
- return typeof this.storage.getObject === 'function' // Prevent runtime error in IE
- ? this.storage.getObject(key)
- : JSON.parse(this.storage.getItem(key) || '{}');
- },
- setObject(key: string, value: unknown) {
- if (typeof this.storage.setObject === 'function') {
- // Prevent runtime error in IE
- this.storage.setObject(key, value);
- } else {
- this.storage.setItem(key, JSON.stringify(value));
- }
- },
- remove(key: string) {
- this.storage.removeItem(key);
- },
- clear() {
- this.storage.clear();
- },
-};
-
-const InScriptStore = function (this: { store: unknown }, object?: unknown) {
- this.store = typeof object !== 'undefined' ? object : {};
-};
-
-export const isEmptyObject = (obj: any) => {
- let is_empty = true;
- if (obj && obj instanceof Object) {
- Object.keys(obj).forEach(key => {
- if (Object.prototype.hasOwnProperty.call(obj, key)) is_empty = false;
- });
- }
- return is_empty;
-};
-
-export const getPropertyValue = (obj: any, k: string | string[]): any => {
- let keys = k;
- if (!Array.isArray(keys)) keys = [keys];
- if (!isEmptyObject(obj) && keys[0] in obj && keys && keys.length > 1) {
- return getPropertyValue(obj[keys[0]], keys.slice(1));
- }
- // else return clone of object to avoid overwriting data
- return obj ? cloneObject(obj[keys[0]]) : undefined;
-};
-
-InScriptStore.prototype = {
- get(key: string) {
- return getPropertyValue(this.store, key);
- },
- set(
- this: { store: any; set: (key: string | string[], value: string, obj: string[]) => void },
- k: string | string[],
- value: string,
- obj = this.store
- ) {
- let key = k;
- if (!Array.isArray(key)) key = [key];
- if (key.length > 1) {
- if (!(key[0] in obj) || isEmptyObject(obj[key[0]])) obj[key[0]] = {};
- this.set(key.slice(1), value, obj[key[0]]);
- } else {
- obj[key[0]] = value;
- }
- },
- getObject(key: string) {
- return JSON.parse(this.get(key) || '{}');
- },
- setObject(key: string, value: unknown) {
- this.set(key, JSON.stringify(value));
- },
- remove(...keys: string[]) {
- keys.forEach(key => {
- delete this.store[key];
- });
- },
- clear() {
- this.store = {};
- },
- has(key: string) {
- return this.get(key) !== undefined;
- },
- keys() {
- return Object.keys(this.store);
- },
- call(key: string) {
- if (typeof this.get(key) === 'function') this.get(key)();
- },
-};
-
-export const State = new (InScriptStore as any)();
-State.prototype = InScriptStore.prototype;
-/**
- * Shorthand function to get values from response object of State
- *
- * @param {String} pathname
- * e.g. getResponse('authorize.currency') == get(['response', 'authorize', 'authorize', 'currency'])
- */
-State.prototype.getResponse = function (pathname: string | string[]) {
- let path = pathname;
- if (typeof path === 'string') {
- const keys = path.split('.');
- path = ['response', keys[0]].concat(keys);
- }
- return this.get(path);
-};
-State.prototype.getByMsgType = State.getResponse;
-State.set('response', {});
-
-export const CookieStorage = function (this: TCookieStorageThis, cookie_name: string, cookie_domain?: string) {
- const hostname = window.location.hostname;
-
- this.initialized = false;
- this.cookie_name = cookie_name;
- this.domain =
- cookie_domain ||
- /* eslint-disable no-nested-ternary */
- (hostname.includes('binary.sx') ? 'binary.sx' : deriv_urls.DERIV_HOST_NAME);
- /* eslint-enable no-nested-ternary */
- this.path = '/';
- this.expires = new Date('Thu, 1 Jan 2037 12:00:00 GMT');
- this.value = {};
-};
-
-CookieStorage.prototype = {
- read() {
- const cookie_value = Cookies.get(this.cookie_name);
- try {
- this.value = cookie_value ? JSON.parse(cookie_value) : {};
- } catch (e) {
- this.value = {};
- }
- this.initialized = true;
- },
- write(val: string, expireDate: Date, isSecure: boolean) {
- if (!this.initialized) this.read();
- this.value = val;
- if (expireDate) this.expires = expireDate;
- Cookies.set(this.cookie_name, this.value, {
- expires: this.expires,
- path: this.path,
- domain: this.domain,
- secure: !!isSecure,
- });
- },
- get(key: string) {
- if (!this.initialized) this.read();
- return this.value[key];
- },
- set(key: string, val: string) {
- if (!this.initialized) this.read();
- this.value[key] = val;
- Cookies.set(this.cookie_name, this.value, {
- expires: new Date(this.expires),
- path: this.path,
- domain: this.domain,
- });
- },
- remove() {
- Cookies.remove(this.cookie_name, {
- path: this.path,
- domain: this.domain,
- });
- },
-};
-
-export const removeCookies = (...cookie_names: string[]) => {
- const domains = [`.${document.domain.split('.').slice(-2).join('.')}`, `.${document.domain}`];
-
- let parent_path = window.location.pathname.split('/', 2)[1];
- if (parent_path !== '') {
- parent_path = `/${parent_path}`;
- }
-
- cookie_names.forEach(c => {
- Cookies.remove(c, { path: '/', domain: domains[0] });
- Cookies.remove(c, { path: '/', domain: domains[1] });
- Cookies.remove(c);
- if (new RegExp(c).test(document.cookie) && parent_path) {
- Cookies.remove(c, { path: parent_path, domain: domains[0] });
- Cookies.remove(c, { path: parent_path, domain: domains[1] });
- Cookies.remove(c, { path: parent_path });
- }
- });
-};
-
-export const LocalStore = isStorageSupported(window.localStorage)
- ? new (Store as any)(window.localStorage)
- : new (InScriptStore as any)();
-export const SessionStore = isStorageSupported(window.sessionStorage)
- ? new (Store as any)(window.sessionStorage)
- : new (InScriptStore as any)();
diff --git a/src/utils/tmp/object-helper.ts b/src/utils/tmp/object-helper.ts
deleted file mode 100644
index 6608f271..00000000
--- a/src/utils/tmp/object-helper.ts
+++ /dev/null
@@ -1,92 +0,0 @@
-/* eslint-disable @typescript-eslint/no-explicit-any */
-export const findValueByKeyRecursively = (obj: Record, key: string) => {
- let return_value;
-
- Object.keys(obj).some(obj_key => {
- const value = obj[obj_key] as Record;
-
- if (obj_key === key) {
- return_value = obj[key];
- return true;
- }
-
- if (typeof value === 'object') {
- const nested_value = findValueByKeyRecursively(value, key);
-
- if (nested_value) {
- return_value = nested_value;
- return true;
- }
- }
-
- return false;
- });
-
- return return_value;
-};
-
-// Recursively freeze an object (deep freeze)
-export const deepFreeze = (obj: Record) => {
- Object.getOwnPropertyNames(obj).forEach(key => {
- const value = obj[key] as Record;
- if (value && typeof value === 'object' && !Object.isFrozen(value)) {
- deepFreeze(value);
- }
- });
- return Object.freeze(obj);
-};
-
-export const isEmptyObject = (obj: Record) => {
- let is_empty = true;
- if (obj && obj instanceof Object) {
- Object.keys(obj).forEach(key => {
- if (Object.prototype.hasOwnProperty.call(obj, key)) is_empty = false;
- });
- }
- return is_empty;
-};
-
-export const cloneObject = (obj: Record) =>
- !isEmptyObject(obj) ? extend(true, Array.isArray(obj) ? [] : {}, obj) : obj;
-
-export const getPropertyValue = (obj: Record, k: string | string[]): unknown => {
- let keys = k;
- if (!Array.isArray(keys)) keys = [keys];
- if (!isEmptyObject(obj) && keys[0] in obj && keys && keys.length > 1) {
- return getPropertyValue(obj[keys[0]] as Record, keys.slice(1));
- }
- // else return clone of object to avoid overwriting data
- return obj ? cloneObject(obj[keys[0]] as Record) : undefined;
-};
-
-function extend(arg0: boolean, arg1: object, obj: Record) {
- if (arg0) {
- return Object.assign(arg1, obj);
- }
- return { ...arg1, ...obj };
-}
-
-export const sequence = (n: number) => Array.from(Array(n).keys());
-
-export const isEqualArray = (arr1: any[], arr2: any[]): boolean =>
- arr1 === arr2 || (arr1.length === arr2.length && arr1.every((value, idx) => isDeepEqual(value, arr2[idx])));
-
-// Note that this function breaks on objects with circular references.
-export const isDeepEqual = (a: any, b: any) => {
- if (typeof a !== typeof b) {
- return false;
- } else if (Array.isArray(a)) {
- return isEqualArray(a, b);
- } else if (a && b && typeof a === 'object') {
- return isEqualObject(a, b);
- } else if (typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b)) {
- return true;
- }
- // else
- return a === b;
-};
-
-export const isEqualObject = (obj1: any, obj2: any): boolean =>
- obj1 === obj2 ||
- (Object.keys(obj1).length === Object.keys(obj2).length &&
- Object.keys(obj1).every(key => isDeepEqual(obj1[key], obj2[key])));
diff --git a/src/utils/tmp/os-detect.ts b/src/utils/tmp/os-detect.ts
deleted file mode 100644
index df5d3b35..00000000
--- a/src/utils/tmp/os-detect.ts
+++ /dev/null
@@ -1,122 +0,0 @@
-// import UAParser from 'ua-parser-js';
-
-declare global {
- interface Window {
- opera?: string;
- MSStream?: {
- readonly type: string;
- msClose: () => void;
- msDetachStream: () => void;
- };
- }
-}
-
-export const systems = {
- mac: ['Mac68K', 'MacIntel', 'MacPPC'],
- linux: [
- 'HP-UX',
- 'Linux i686',
- 'Linux amd64',
- 'Linux i686 on x86_64',
- 'Linux i686 X11',
- 'Linux x86_64',
- 'Linux x86_64 X11',
- 'FreeBSD',
- 'FreeBSD i386',
- 'FreeBSD amd64',
- 'X11',
- ],
- ios: ['iPhone', 'iPod', 'iPad', 'iPhone Simulator', 'iPod Simulator', 'iPad Simulator'],
- android: [
- 'Android',
- 'Linux armv7l', // Samsung galaxy s2 ~ s5, nexus 4/5
- 'Linux armv8l',
- null,
- ],
- windows: ['Win16', 'Win32', 'Win64', 'WinCE'],
-};
-
-export const isDesktopOs = () => {
- const os = OSDetect();
- return !!['windows', 'mac', 'linux'].find(system => system === os);
-};
-
-export const isMobileOs = () =>
- /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
-
-export const OSDetect = () => {
- // For testing purposes or more compatibility, if we set 'config.os'
- // inside our localStorage, we ignore fetching information from
- // navigator object and return what we have straight away.
- if (localStorage.getItem('config.os')) {
- return localStorage.getItem('config.os');
- }
- if (typeof navigator !== 'undefined' && navigator.platform) {
- return Object.keys(systems)
- .map(os => {
- if (systems[os as keyof typeof systems].some(platform => navigator.platform === platform)) {
- return os;
- }
- return false;
- })
- .filter(os => os)[0];
- }
-
- return 'Unknown OS';
-};
-
-export const mobileOSDetect = () => {
- const userAgent = navigator.userAgent || navigator.vendor || window.opera || '';
- // huawei devices regex from: https://gist.github.com/megaacheyounes/e1c7eec5c790e577db602381b8c50bfa
- const huaweiDevicesRegex =
- /\bK\b|ALP-|AMN-|ANA-|ANE-|ANG-|AQM-|ARS-|ART-|ATU-|BAC-|BLA-|BRQ-|CAG-|CAM-|CAN-|CAZ-|CDL-|CDY-|CLT-|CRO-|CUN-|DIG-|DRA-|DUA-|DUB-|DVC-|ELE-|ELS-|EML-|EVA-|EVR-|FIG-|FLA-|FRL-|GLK-|HMA-|HW-|HWI-|INE-|JAT-|JEF-|JER-|JKM-|JNY-|JSC-|LDN-|LIO-|LON-|LUA-|LYA-|LYO-|MAR-|MED-|MHA-|MLA-|MRD-|MYA-|NCE-|NEO-|NOH-|NOP-|OCE-|PAR-|PIC-|POT-|PPA-|PRA-|RNE-|SEA-|SLA-|SNE-|SPN-|STK-|TAH-|TAS-|TET-|TRT-|VCE-|VIE-|VKY-|VNS-|VOG-|VTR-|WAS-|WKG-|WLZ-|JAD-|WKG-|MLD-|RTE-|NAM-|NEN-|BAL-|JAD-|JLN-|YAL/i;
-
- // Windows Phone must come first because its UA also contains "Android"
- if (/windows phone/i.test(userAgent)) {
- return 'Windows Phone';
- }
-
- if (/android/i.test(userAgent)) {
- // Huawei UA is the same as android so we have to detect by the model
- if (huaweiDevicesRegex.test(userAgent) || /huawei/i.test(userAgent)) {
- return 'huawei';
- }
- return 'Android';
- }
-
- // iOS detection from: http://stackoverflow.com/a/9039885/177710
- if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
- return 'iOS';
- }
-
- return 'unknown';
-};
-
-// export const getOSNameWithUAParser = () => UAParser().os.name;
-
-export const isSafari = () => {
- return (
- /constructor/i.test(window.HTMLElement) ||
- (function (p) {
- return p.toString() === '[object SafariRemoteNotification]';
- })(!window.safari || (typeof window.safari !== 'undefined' && window.safari.pushNotification))
- );
-};
-
-const getUserBrowser = () => {
- // We can't rely only on navigator.userAgent.index, the verification order is also important
- if ((navigator.userAgent.indexOf('Opera') || navigator.userAgent.indexOf('OPR')) !== -1) {
- return 'Opera';
- } else if (navigator.userAgent.indexOf('Edg') !== -1) {
- return 'Edge';
- } else if (navigator.userAgent.indexOf('Chrome') !== -1) {
- return 'Chrome';
- } else if (navigator.userAgent.indexOf('Safari') !== -1) {
- return 'Safari';
- } else if (navigator.userAgent.indexOf('Firefox') !== -1) {
- return 'Firefox';
- }
- return 'unknown';
-};
-
-export const isSafariBrowser = () => getUserBrowser() === 'Safari';
diff --git a/src/utils/tmp/time-helper.ts b/src/utils/tmp/time-helper.ts
deleted file mode 100644
index f65ea2fd..00000000
--- a/src/utils/tmp/time-helper.ts
+++ /dev/null
@@ -1,314 +0,0 @@
-import moment from 'moment';
-
-import { getLanguage, localize } from './dummy';
-
-type TExtendedMoment = typeof moment & {
- createFromInputFallback: (config: { _d: Date }) => void;
-};
-
-// Disables moment's fallback to native Date object
-// moment will return `Invalid Date` if date cannot be parsed
-(moment as TExtendedMoment).createFromInputFallback = function (config) {
- config._d = new Date(NaN); // eslint-disable-line no-underscore-dangle
-};
-
-// Localize moment instance with specific object
-export const initMoment = (lang: string) => {
- const ignored_language = ['EN', 'AR', 'BN', 'SI'];
- if (!lang || ignored_language.includes(lang)) return moment;
- // TODO: Fix
- return import(
- /* @vite-ignore */
- `moment/locale/${lang.toLowerCase().replace('_', '-')}`
- )
- .then(() => moment.locale(lang.toLocaleLowerCase().replace('_', '-')))
- .catch(() => moment);
-};
-
-/**
- * Convert epoch to moment object
- * @param {Number} epoch
- * @return {moment} the moment object of provided epoch
- */
-export const epochToMoment = (epoch: number) => moment.unix(epoch).utc();
-
-/**
- * Convert date string or epoch to moment object
- * @param {Number} value the date in epoch format
- * @param {String} value the date in string format
- * @return {moment} the moment object of 'now' or the provided date epoch or string
- */
-export const toMoment = (value?: moment.MomentInput): moment.Moment => {
- if (!value) return moment().utc(); // returns 'now' moment object
- if (value instanceof moment && (value as moment.Moment).isValid() && (value as moment.Moment).isUTC())
- return value as moment.Moment; // returns if already a moment object
- if (typeof value === 'number') return epochToMoment(value); // returns epochToMoment() if not a date
-
- if (/invalid/i.test(moment(value).toString())) {
- const today_moment = moment();
- const days_in_month = today_moment.utc().daysInMonth();
- const value_as_number = moment.utc(value, 'DD MMM YYYY').valueOf() / (1000 * 60 * 60 * 24);
- return value_as_number > days_in_month
- ? moment.utc(today_moment.add(value as string | number, 'd'), 'DD MMM YYYY')
- : moment.utc(value, 'DD MMM YYYY'); // returns target date
- }
- return moment.utc(value);
-};
-
-export const toLocalFormat = (time: moment.MomentInput) => moment.utc(time).local().format('YYYY-MM-DD HH:mm:ss Z');
-export const getLongDate = (time: number): string => {
- moment.locale(getLanguage().toLowerCase());
- //need to divide to 1000 as timestamp coming from BE is in ms
- return moment.unix(time / 1000).format('MMMM Do, YYYY');
-};
-
-/**
- * Set specified time on moment object
- * @param {moment} moment_obj the moment to set the time on
- * @param {String} time 24 hours format, may or may not include seconds
- * @return {moment} a new moment object of result
- */
-export const setTime = (moment_obj: moment.Moment, time: string | null) => {
- const [hour, minute, second] = time ? time.split(':') : [0, 0, 0];
- moment_obj
- .hour(+hour)
- .minute(+minute || 0)
- .second(+second || 0);
- return moment_obj;
-};
-
-/**
- * return the unix value of provided epoch and time
- * @param {Number} epoch the date to update with provided time
- * @param {String} time the time to set on the date
- * @return {Number} unix value of the result
- */
-export const convertToUnix = (epoch: number | string, time: string) => setTime(toMoment(epoch), time).unix();
-
-export const toGMTFormat = (time?: moment.MomentInput) =>
- moment(time || undefined)
- .utc()
- .format('YYYY-MM-DD HH:mm:ss [GMT]');
-
-export const formatDate = (date?: moment.MomentInput, date_format = 'YYYY-MM-DD', should_format_null = true) =>
- !should_format_null && date === null ? undefined : toMoment(date).format(date_format);
-
-export const formatTime = (epoch: number | string, time_format = 'HH:mm:ss [GMT]') =>
- toMoment(epoch).format(time_format);
-
-/**
- * return the number of days from today to date specified
- * @param {String} date the date to calculate number of days from today
- * @return {Number} an integer of the number of days
- */
-export const daysFromTodayTo = (date?: string | moment.Moment) => {
- const diff = toMoment(date).startOf('day').diff(toMoment().startOf('day'), 'days');
- return !date || diff < 0 ? '' : diff;
-};
-
-/**
- * return the number of days since the date specified
- * @param {String} date the date to calculate number of days since
- * @return {Number} an integer of the number of days
- */
-export const daysSince = (date: string) => {
- const diff = toMoment().startOf('day').diff(toMoment(date).startOf('day'), 'days');
- return !date ? '' : diff;
-};
-
-/**
- * return the number of months between two specified dates
- */
-export const diffInMonths = (now: moment.MomentInput, then: moment.Moment) => then.diff(now, 'month');
-/**
- * return moment duration between two dates
- * @param {Number} epoch start time
- * @param {Number} epoch end time
- * @return {moment.duration} moment duration between start time and end time
- */
-export const getDiffDuration = (start_time: number, end_time: number) =>
- moment.duration(moment.unix(end_time).diff(moment.unix(start_time)));
-
-/** returns the DD MM YYYY format */
-export const getDateFromNow = (
- days: string | number,
- unit?: moment.unitOfTime.DurationConstructor,
- format?: string
-) => {
- const date = moment(new Date());
- return date.add(days, unit).format(format);
-};
-
-/**
- * return formatted duration `2 days 01:23:59`
- * @param {moment.duration} moment duration object
- * @return {String} formatted display string
- */
-export const formatDuration = (duration: moment.Duration, format?: string) => {
- const d = Math.floor(duration.asDays()); // duration.days() does not include months/years
- const h = duration.hours();
- const m = duration.minutes();
- const s = duration.seconds();
- const formatted_str = moment(0)
- .hour(h)
- .minute(m)
- .seconds(s)
- .format(format || 'HH:mm:ss');
-
- return {
- days: d,
- timestamp: formatted_str,
- };
-};
-
-/**
- * return true if the time_str is in "HH:MM" format, else return false
- * @param {String} time_str time
- */
-export const isTimeValid = (time_str: string) =>
- /^([0-9]|[0-1][0-9]|2[0-3]):([0-9]|[0-5][0-9])(:([0-9]|[0-5][0-9]))?$/.test(time_str);
-
-/**
- * return true if the time_str's hour is between 0 and 23, else return false
- * @param {String} time_str time
- */
-export const isHourValid = (time_str: string) =>
- isTimeValid(time_str) && /^([01][0-9]|2[0-3])$/.test(time_str.split(':')[0]);
-
-/**
- * return true if the time_str's minute is between 0 and 59, else return false
- * @param {String} time_str time
- */
-export const isMinuteValid = (time_str: string) => isTimeValid(time_str) && /^[0-5][0-9]$/.test(time_str.split(':')[1]);
-
-/**
- * return true if the date is typeof string and a valid moment date, else return false
- * @param {String|moment} date date
- */
-export const isDateValid = (date: moment.MomentInput) => moment(date, 'DD MMM YYYY').isValid();
-
-/**
- * add the specified number of days to the given date
- * @param {String} date date
- * @param {Number} num_of_days number of days to add
- */
-export const addDays = (date: string | moment.Moment, num_of_days: number) =>
- toMoment(date).clone().add(num_of_days, 'day');
-
-/**
- * add the specified number of weeks to the given date
- * @param {String} date date
- * @param {Number} num_of_weeks number of days to add
- */
-export const addWeeks = (date: string, num_of_weeks: number) => toMoment(date).clone().add(num_of_weeks, 'week');
-
-/**
- * add the specified number of months to the given date
- * @param {String} date date
- * @param {Number} num_of_months number of months to add
- */
-export const addMonths = (date: moment.MomentInput, num_of_months: number) =>
- toMoment(date).clone().add(num_of_months, 'month');
-
-/**
- * add the specified number of years to the given date
- * @param {String} date date
- * @param {Number} num_of_years number of years to add
- */
-export const addYears = (date: moment.MomentInput, num_of_years: number) =>
- toMoment(date).clone().add(num_of_years, 'year');
-
-/**
- * subtract the specified number of days from the given date
- * @param {String} date date
- * @param {Number} num_of_days number of days to subtract
- */
-export const subDays = (date: moment.MomentInput, num_of_days: number) =>
- toMoment(date).clone().subtract(num_of_days, 'day');
-
-/**
- * subtract the specified number of months from the given date
- * @param {String} date date
- * @param {Number} num_of_months number of months to subtract
- */
-export const subMonths = (date: moment.MomentInput, num_of_months: number) =>
- toMoment(date).clone().subtract(num_of_months, 'month');
-
-/**
- * subtract the specified number of years from the given date
- * @param {String} date date
- * @param {Number} num_of_years number of years to subtract
- */
-export const subYears = (date: moment.MomentInput, num_of_years: number) =>
- toMoment(date).clone().subtract(num_of_years, 'year');
-
-/**
- * returns the minimum moment between the two passing parameters
- * @param {moment|string|epoch} first datetime parameter
- * @param {moment|string|epoch} second datetime parameter
- */
-export const minDate = (date_1: moment.MomentInput, date_2: moment.MomentInput) =>
- moment.min(toMoment(date_1), toMoment(date_2));
-
-/**
- * returns a new date
- * @param {moment|string|epoch} date date
- */
-export const getStartOfMonth = (date: moment.MomentInput) =>
- toMoment(date).clone().startOf('month').format('YYYY-MM-DD');
-
-/**
- * returns miliseconds into UTC formatted string
- * @param {Number} miliseconds miliseconds
- * @param {String} str_format formatting using moment e.g - YYYY-MM-DD HH:mm
- */
-export const formatMilliseconds = (miliseconds: moment.MomentInput, str_format: string, is_local_time = false) => {
- if (is_local_time) {
- return moment(miliseconds).format(str_format);
- }
- return moment.utc(miliseconds).format(str_format);
-};
-
-/**
- * returns a new date string
- * @param {moment|string|epoch} date parameter
- * @param {String} from_date_format initial date format
- * @param {String} to_date_format to date format
- */
-export const convertDateFormat = (date: moment.MomentInput, from_date_format: string, to_date_format: string) =>
- moment(date, from_date_format).format(to_date_format);
-
-/**
- * Convert 24 hours format time to 12 hours formatted time.
- * @param {String} time 24 hours format, may or may not include seconds
- * @return {String} equivalent 12-hour time
- */
-export const convertTimeFormat = (time: string) => {
- const time_moment_obj = moment(time, 'HH:mm');
- const time_hour = time_moment_obj.format('HH');
- const time_min = time_moment_obj.format('mm');
- const formatted_time = `${Number(time_hour) % 12 || 12}:${time_min}`;
- const time_suffix = `${Number(time_hour) >= 12 ? 'pm' : 'am'}`;
- return `${formatted_time} ${time_suffix}`;
-};
-
-/**
- * Get a formatted time since a timestamp.
- * @param {Number} timestamp in ms
- * @return {String} '10s ago', or '1m ago', or '1h ago', or '1d ago'
- */
-export const getTimeSince = (timestamp: number) => {
- if (!timestamp) return '';
- const seconds_passed = Math.floor((Date.now() - timestamp) / 1000);
-
- if (seconds_passed < 60) {
- return localize('{{seconds_passed}}s ago', { seconds_passed });
- }
- if (seconds_passed < 3600) {
- return localize('{{minutes_passed}}m ago', { minutes_passed: Math.floor(seconds_passed / 60) });
- }
- if (seconds_passed < 86400) {
- return localize('{{hours_passed}}h ago', { hours_passed: Math.floor(seconds_passed / 3600) });
- }
- return localize('{{days_passed}}d ago', { days_passed: Math.floor(seconds_passed / (3600 * 24)) });
-};
diff --git a/vite.config.ts b/vite.config.ts
index 4ff12f0e..45931c2e 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -38,6 +38,9 @@ export default defineConfig({
@import "src/components/shared/styles/devices.scss";
@import "src/components/shared/styles/fonts.scss";
@import "src/components/shared/styles/mixins.scss";
+ @import "src/components/shared/styles/reset.scss";
+ @import "src/components/shared/styles/inline-icons.scss";
+ @import "src/components/shared/styles/google-fonts.scss";
@import "src/styles/mixins.scss";
`,
},