Skip to content

Commit

Permalink
Merge branch 'master' into amina/feature/90115/update_jurisdiction
Browse files Browse the repository at this point in the history
  • Loading branch information
amina-deriv authored Jun 1, 2023
2 parents c66f332 + 1da4c97 commit a06ddb9
Show file tree
Hide file tree
Showing 28 changed files with 99 additions and 50 deletions.
7 changes: 4 additions & 3 deletions packages/account/build/loaders-config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const { IS_RELEASE } = require('./constants');

const js_loaders = [
{
Expand Down Expand Up @@ -66,13 +67,13 @@ const css_loaders = [
{
loader: 'css-loader',
options: {
sourceMap: true,
sourceMap: !IS_RELEASE,
},
},
{
loader: 'postcss-loader',
options: {
sourceMap: true,
sourceMap: !IS_RELEASE,
postcssOptions: {
config: path.resolve(__dirname),
},
Expand All @@ -88,7 +89,7 @@ const css_loaders = [
{
loader: 'sass-loader',
options: {
sourceMap: true,
sourceMap: !IS_RELEASE,
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/account/build/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function (env) {

return {
context: path.resolve(__dirname, '../src'),
devtool: IS_RELEASE ? undefined : 'eval-cheap-module-source-map',
devtool: IS_RELEASE ? 'source-map' : 'eval-cheap-module-source-map',
entry: {
account: path.resolve(__dirname, '../src', 'index.tsx'),
'accept-risk-config': 'Configs/accept-risk-config',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { usePlatformAccounts } from '@deriv/hooks';
import { useStore, observer } from '@deriv/stores';

const DemoAccountCard = observer(() => {
const { client, traders_hub } = useStore();
const { client, traders_hub, common } = useStore();
const { accounts, loginid, resetVirtualBalance, default_currency } = client;
const { selected_account_type } = traders_hub;
const { demo: platform_demo_account } = usePlatformAccounts();
Expand All @@ -17,6 +17,8 @@ const DemoAccountCard = observer(() => {
return loginid && (accounts[loginid]?.balance || 0) !== 10000;
};

const { current_language } = common;

return (
<CurrencySwitcherContainer
className='demo-account-card'
Expand All @@ -28,7 +30,12 @@ const DemoAccountCard = observer(() => {
}
actions={
canResetBalance() && (
<Button secondary onClick={resetVirtualBalance} className='currency-switcher__button'>
<Button
key={`currency-switcher__button--key-${current_language}`}
secondary
onClick={resetVirtualBalance}
className='currency-switcher__button'
>
{localize('Reset Balance')}
</Button>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const RealAccountCard = observer(() => {
<Button
onClick={(e: MouseEvent) => {
e.stopPropagation();
history.push(routes.cashier_deposit);
history.push(`${routes.cashier_deposit}#deposit`);
}}
secondary
className='currency-switcher__button'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import TotalAssetsLoader from 'Components/pre-loader/total-assets-loader';
import { useTotalAccountBalance, useCFDAccounts, usePlatformAccounts } from '@deriv/hooks';

const AssetSummary = observer(() => {
const { traders_hub, client } = useStore();
const { traders_hub, client, common } = useStore();
const { selected_account_type, is_eu_user, no_CR_account, no_MF_account } = traders_hub;
const { is_logging_in, is_switching, default_currency } = client;
const { current_language } = common;
const { real: platform_real_accounts, demo: platform_demo_account } = usePlatformAccounts();
const { real: cfd_real_accounts, demo: cfd_demo_accounts } = useCFDAccounts();
const platform_real_balance = useTotalAccountBalance(platform_real_accounts);
Expand Down Expand Up @@ -41,7 +42,7 @@ const AssetSummary = observer(() => {
{has_active_related_deriv_account || selected_account_type === 'demo' ? (
<React.Fragment>
{!isMobile() ? (
<Text align='right' size='xs' line_height='s'>
<Text align='right' key={`asset-summary--key-${current_language}`} size='xs' line_height='s'>
{localize('Total assets')}
</Text>
) : null}
Expand Down
2 changes: 1 addition & 1 deletion packages/appstore/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ module.exports = function (env) {
]
: [],
},
devtool: is_release ? undefined : 'eval-cheap-module-source-map',
devtool: is_release ? 'source-map' : 'eval-cheap-module-source-map',
externals: [
{
react: true,
Expand Down
10 changes: 5 additions & 5 deletions packages/bot-web-ui/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const path = require('path');
const StyleLintPlugin = require('stylelint-webpack-plugin');
const SpriteLoaderPlugin = require('svg-sprite-loader/plugin');

const is_release = process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'staging';
const IS_RELEASE = process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'staging';

const output = {
path: path.resolve(__dirname, 'dist'),
Expand All @@ -31,8 +31,8 @@ module.exports = function (env) {
publicPath: '/dist/',
disableHostCheck: true,
},
mode: is_release ? 'production' : 'development',
devtool: is_release ? undefined : 'eval-cheap-module-source-map',
mode: IS_RELEASE ? 'production' : 'development',
devtool: IS_RELEASE ? 'source-map' : 'eval-cheap-module-source-map',
target: 'web',
module: {
rules: [
Expand All @@ -52,13 +52,13 @@ module.exports = function (env) {
{
loader: 'css-loader',
options: {
sourceMap: true,
sourceMap: !IS_RELEASE,
url: false,
},
},
{
loader: 'sass-loader',
options: { sourceMap: true },
options: { sourceMap: !IS_RELEASE },
},
{
loader: 'sass-resources-loader',
Expand Down
7 changes: 4 additions & 3 deletions packages/cashier/build/loaders-config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const { IS_RELEASE } = require('./constants');

const js_loaders = [
{
Expand Down Expand Up @@ -69,13 +70,13 @@ const css_loaders = [
{
loader: 'css-loader',
options: {
sourceMap: true,
sourceMap: !IS_RELEASE,
},
},
{
loader: 'postcss-loader',
options: {
sourceMap: true,
sourceMap: !IS_RELEASE,
postcssOptions: {
config: path.resolve(__dirname),
},
Expand All @@ -91,7 +92,7 @@ const css_loaders = [
{
loader: 'sass-loader',
options: {
sourceMap: true,
sourceMap: !IS_RELEASE,
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/cashier/build/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function (env) {

return {
context: path.resolve(__dirname, '../src'),
devtool: IS_RELEASE ? undefined : 'eval-cheap-module-source-map',
devtool: IS_RELEASE ? 'source-map' : 'eval-cheap-module-source-map',
entry: {
cashier: path.resolve(__dirname, '../src', 'index.tsx'),
'cashier-store': 'Stores/cashier-store',
Expand Down
4 changes: 3 additions & 1 deletion packages/cashier/src/app-content.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react';
import Routes from 'Containers/routes';
import { observer, useStore } from '@deriv/stores';
import { useTheme } from '@deriv/ui';
import Routes from './containers/routes';
import useUnsafeCashierRouteHandler from './containers/routes/useUnsafeCashierRouteHandler';

const AppContent = observer(() => {
const { ui } = useStore();
const { is_dark_mode_on, notification_messages_ui: Notifications } = ui;
const { setColorMode } = useTheme();
useUnsafeCashierRouteHandler();

React.useEffect(() => {
const theme = (is_dark_mode_on ? 'dark' : 'light') as Parameters<typeof setColorMode>[0];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { useEffect } from 'react';
import { routes } from '@deriv/shared';
import { useCashierStore } from 'Stores/useCashierStores';
import { RouterChildContext, useHistory } from 'react-router';

/** @deprecated This is a temporary solution to handle routing in cashier. */
const useUnsafeCashierRouteHandler = () => {
const history: RouterChildContext['router']['history'] = useHistory();
const { transaction_history, general_store } = useCashierStore();
const { setIsCryptoTransactionsVisible } = transaction_history;
const { setIsCashierOnboarding, setIsDeposit } = general_store;

useEffect(() => {
const destination_hash = history.location.hash;
const is_current_route_deposit = history.location.pathname === routes.cashier_deposit;
const is_hash_cashier_onboarding = destination_hash === '#cashier_onboarding';
const is_hash_deposit = destination_hash === '#deposit';
const is_hash_crypto_transactions_visible = destination_hash === '#crypto_transactions';

if (is_current_route_deposit) {
setIsCashierOnboarding(is_hash_cashier_onboarding);
setIsDeposit(is_hash_deposit);
setIsCryptoTransactionsVisible(is_hash_crypto_transactions_visible);

history.replace({ pathname: history.location.pathname, hash: '' });
}
}, [history, setIsCashierOnboarding, setIsCryptoTransactionsVisible, setIsDeposit]);
};

export default useUnsafeCashierRouteHandler;
7 changes: 4 additions & 3 deletions packages/cfd/build/loaders-config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const { IS_RELEASE } = require('./constants');

const js_loaders = [
{
Expand Down Expand Up @@ -69,13 +70,13 @@ const css_loaders = [
{
loader: 'css-loader',
options: {
sourceMap: true,
sourceMap: !IS_RELEASE,
},
},
{
loader: 'postcss-loader',
options: {
sourceMap: true,
sourceMap: !IS_RELEASE,
postcssOptions: {
config: path.resolve(__dirname),
},
Expand All @@ -91,7 +92,7 @@ const css_loaders = [
{
loader: 'sass-loader',
options: {
sourceMap: true,
sourceMap: !IS_RELEASE,
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/cfd/build/webpack.config-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = function (env) {

return {
context: path.resolve(__dirname, '../src'),
devtool: IS_RELEASE ? undefined : 'eval-cheap-module-source-map',
devtool: IS_RELEASE ? 'source-map' : 'eval-cheap-module-source-map',
entry: './index.js',
externals: [nodeExternals()],
mode: IS_RELEASE ? 'development' : 'production',
Expand Down
2 changes: 1 addition & 1 deletion packages/cfd/build/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function (env) {

return {
context: path.resolve(__dirname, '../'),
devtool: IS_RELEASE ? undefined : 'eval-cheap-module-source-map',
devtool: IS_RELEASE ? 'source-map' : 'eval-cheap-module-source-map',
entry: {
cfd: path.resolve(__dirname, '../src', 'index.tsx'),
CFDStore: 'Stores/Modules/CFD/cfd-store',
Expand Down
7 changes: 4 additions & 3 deletions packages/core/build/loaders-config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const { IS_RELEASE } = require('./constants');

const js_loaders = [
'@deriv/shared/src/loaders/deriv-account-loader.js',
Expand Down Expand Up @@ -80,13 +81,13 @@ const css_loaders = [
{
loader: 'css-loader',
options: {
sourceMap: true,
sourceMap: !IS_RELEASE,
},
},
{
loader: 'postcss-loader',
options: {
sourceMap: true,
sourceMap: !IS_RELEASE,
postcssOptions: {
config: path.resolve(__dirname),
},
Expand All @@ -102,7 +103,7 @@ const css_loaders = [
{
loader: 'sass-loader',
options: {
sourceMap: true,
sourceMap: !IS_RELEASE,
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/core/build/webpack.config-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = function (env) {

return {
context: path.resolve(__dirname, '../src'),
devtool: IS_RELEASE ? undefined : 'eval-cheap-module-source-map',
devtool: IS_RELEASE ? 'source-map' : 'eval-cheap-module-source-map',
entry: './index.js',
externals: [nodeExternals()],
mode: IS_RELEASE ? 'development' : 'production',
Expand Down
2 changes: 1 addition & 1 deletion packages/core/build/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = function (env) {
colors: true,
},
},
devtool: IS_RELEASE ? undefined : 'eval-cheap-module-source-map',
devtool: IS_RELEASE ? 'source-map' : 'eval-cheap-module-source-map',
entry: './index.tsx',
mode: IS_RELEASE ? 'production' : 'development',
module: {
Expand Down
2 changes: 1 addition & 1 deletion packages/p2p/src/stores/buy-sell-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ export default class BuySellStore extends BaseStore {
const old_items = [...this.items];
const new_items = [];

list.forEach(new_item => {
list?.forEach(new_item => {
const old_item_idx = old_items.findIndex(old_item => old_item.id === new_item.id);

if (old_item_idx > -1) {
Expand Down
6 changes: 3 additions & 3 deletions packages/p2p/src/stores/general-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export default class GeneralStore extends BaseStore {
const { order_store } = this.root_store;
const { is_cached, notifications } = this.getLocalStorageSettingsForLoginId();

new_orders.forEach(new_order => {
new_orders?.forEach(new_order => {
const order_info = createExtendedOrderDetails(
new_order,
this.external_stores.client.loginid,
Expand Down Expand Up @@ -738,14 +738,14 @@ export default class GeneralStore extends BaseStore {
return;
}

const { p2p_order_list = [], p2p_order_info = {} } = order_response;
const { p2p_order_list, p2p_order_info } = order_response ?? {};
const { order_store } = this.root_store;

if (p2p_order_list) {
const { list } = p2p_order_list;
// it's an array of orders from p2p_order_list
this.handleNotifications(order_store.orders, list);
list.forEach(order => order_store.syncOrder(order));
list?.forEach(order => order_store.syncOrder(order));
} else if (p2p_order_info) {
// it's a single order from p2p_order_info
const idx_order_to_update = order_store.orders.findIndex(order => order.id === p2p_order_info.id);
Expand Down
11 changes: 7 additions & 4 deletions packages/p2p/src/stores/order-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,13 @@ export default class OrderStore {
this.setErrorMessage(response.error.message);
} else {
const { p2p_order_list } = response;
const { list } = p2p_order_list || {};

this.root_store.general_store.handleNotifications(this.orders, p2p_order_list.list);
p2p_order_list.list.forEach(order => this.syncOrder(order));
this.setOrders(p2p_order_list.list);
if (list?.length) {
this.root_store.general_store.handleNotifications(this.orders, list);
list.forEach(order => this.syncOrder(order));
this.setOrders(list);
}
}
}
});
Expand Down Expand Up @@ -263,7 +266,7 @@ export default class OrderStore {
const old_list = [...this.orders];
const new_list = [];

list.forEach(order => {
list?.forEach(order => {
const old_list_idx = old_list.findIndex(o => o.id === order.id);

if (old_list_idx > -1) {
Expand Down
Loading

0 comments on commit a06ddb9

Please sign in to comment.