Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into p2p-modal-test
Browse files Browse the repository at this point in the history
  • Loading branch information
farrah-deriv committed Sep 28, 2023
2 parents aa3f39b + 4dae936 commit 018f1e9
Show file tree
Hide file tree
Showing 319 changed files with 5,310 additions and 2,845 deletions.
22 changes: 22 additions & 0 deletions eslint-local-rules/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
/** This rule is used to prevent the use of `React` namespace. ex: `React.useEffect` -> `useEffect` */
'no-react-namespace': {
create(context) {
return {
MemberExpression(node) {
if (node.object.type === 'Identifier' && node.object.name === 'React') {
context.report({
node,
message: `Use ${node.property.name} instead of React.${node.property.name}.`,
fix: fixer => {
const start = node.object.range[0];
const end = node.object.range[1] + 1;
return fixer.removeRange([start, end]);
},
});
}
},
};
},
},
};
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,7 @@ describe('<AccountLimits/>', () => {
);

expect(
screen.getByRole('cell', {
name: /your account is fully authenticated and your withdrawal limits have been lifted\./i,
})
screen.getByText(/your account is fully authenticated and your withdrawal limits have been lifted\./i)
).toBeInTheDocument();
});

Expand Down Expand Up @@ -473,7 +471,7 @@ describe('<AccountLimits/>', () => {
expect(formatMoney).toHaveBeenCalledWith(store.client.currency, remainder, true);
});

it('should show limit_notice message when is_appstore is true and is_fully_authenticated is false in mobile mode', () => {
it('should show limit_notice message when is_appstore is false and is_fully_authenticated is false in mobile mode', () => {
store = mockStore({
client: {
...mock.client,
Expand All @@ -483,7 +481,7 @@ describe('<AccountLimits/>', () => {
(isMobile as jest.Mock).mockReturnValue(true);
(isDesktop as jest.Mock).mockReturnValue(false);
render(
<PlatformContext.Provider value={{ is_appstore: true, is_deriv_crypto: false, is_pre_appstore: false }}>
<PlatformContext.Provider value={{ is_appstore: false, is_deriv_crypto: false, is_pre_appstore: false }}>
<BrowserRouter>
<StoreProvider store={store}>
<AccountLimits {...props} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@
}

&__text-container {
margin: 1.2rem 0;

&:last-child {
margin-bottom: 0;
}
margin: 1.2rem 1.2rem 1.2rem 0;
}

&__popover {
Expand Down
22 changes: 13 additions & 9 deletions packages/account/src/Components/account-limits/account-limits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,18 @@ const AccountLimits = observer(
should_show_article = true,
}: TAccountLimits) => {
const { client, common } = useStore();
const { account_limits, currency, getLimits, is_virtual, is_switching } = client;
const {
account_limits,
account_status,
currency,
getLimits,
is_fully_authenticated,
is_virtual,
is_switching,
} = client;
const { is_from_derivgo } = common;
const isMounted = useIsMounted();
const [is_loading, setLoading] = React.useState(false);
const [is_loading, setLoading] = React.useState(true);
const [is_overlay_shown, setIsOverlayShown] = React.useState(false);
const { is_appstore } = React.useContext(PlatformContext);

Expand All @@ -58,10 +66,10 @@ const AccountLimits = observer(
}, []);

React.useEffect(() => {
if (!is_virtual && account_limits && is_loading) {
if (!is_virtual && account_limits && is_loading && Object.keys(account_status).length > 0) {
setLoading(false);
}
}, [account_limits, is_virtual, is_loading]);
}, [account_limits, is_virtual, is_loading, account_status]);

React.useEffect(() => {
if (typeof setIsPopupOverlayShown === 'function') {
Expand All @@ -71,7 +79,7 @@ const AccountLimits = observer(

const toggleOverlay = () => setIsOverlayShown(!is_overlay_shown);

if (is_switching) {
if (is_switching || is_loading) {
return <Loading is_fullscreen={false} />;
}

Expand Down Expand Up @@ -103,10 +111,6 @@ const AccountLimits = observer(
return <LoadErrorMessage error_message={api_initial_load_error} />;
}

if (is_switching || is_loading) {
return <Loading is_fullscreen={false} />;
}

const { commodities, forex, indices, synthetic_index } = { ...market_specific };
const forex_ordered = forex?.slice().sort((a: FormikValues, b: FormikValues) => a.name.localeCompare(b.name));
const derived_ordered = synthetic_index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,7 @@ const WithdrawalLimitsTable = observer(
</tr>
</thead>
<tbody>
{is_fully_authenticated ? (
<tr>
<AccountLimitsTableCell>
<Text size='xxs' color='prominent'>
{localize(
'Your account is fully authenticated and your withdrawal limits have been lifted.'
)}
</Text>
</AccountLimitsTableCell>
<AccountLimitsTableCell />
</tr>
) : (
{!is_fully_authenticated && (
<React.Fragment>
<tr>
<AccountLimitsTableCell>
Expand Down Expand Up @@ -113,16 +102,18 @@ const WithdrawalLimitsTable = observer(
)}
</tbody>
</table>
{(!is_appstore || isMobile()) && (
<div className='da-account-limits__text-container'>
<Text as='p' size='xxs' color='less-prominent' line_height='xs'>
{is_fully_authenticated ? (
<Localize i18n_default_text='Your account is fully authenticated and your withdrawal limits have been lifted.' />
) : (
<Localize i18n_default_text='Stated limits are subject to change without prior notice.' />
)}
</Text>
</div>
{!is_appstore && (
<tr>
<div className='da-account-limits__text-container'>
<Text as='p' size='xxs' color='less-prominent' line_height='xs'>
{is_fully_authenticated ? (
<Localize i18n_default_text='Your account is fully authenticated and your withdrawal limits have been lifted.' />
) : (
<Localize i18n_default_text='Stated limits are subject to change without prior notice.' />
)}
</Text>
</div>
</tr>
)}
</React.Fragment>
);
Expand Down
69 changes: 63 additions & 6 deletions packages/analytics/src/rudderstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,52 @@ type VirtualSignupEmailConfirmationAction = {
error_message?: string;
};

type IndicatorsTypesFormAction = {
action:
| 'open'
| 'close'
| 'add_active'
| 'clean_all_active'
| 'delete_active'
| 'edit_active'
| 'search'
| 'info_open'
| 'info_close';
form_name?: string;
indicator_type_name?: string;
indicators_category_name?: string;
search_string?: string;
subform_name?: string;
account_type: string;
device_type: string;
};

type MarketTypesFormAction = {
action:
| 'open'
| 'close'
| 'choose_market_type'
| 'search'
| 'info_redirect'
| 'add_to_favorites'
| 'delete_from_favorites';
form_name: string;
market_type_name: string;
search_string?: string;
tab_market_name?: string;
account_type: string;
device_type: string;
};

type ChartTypesFormAction = {
action: 'open' | 'close' | 'choose_chart_type' | 'choose_time_interval';
form_name: string;
chart_type_name: string;
time_interval_name: string;
account_type: string;
device_type: string;
};

type TradeTypesFormAction =
| {
action: 'open' | 'close' | 'info_close';
Expand All @@ -59,14 +105,14 @@ type TradeTypesFormAction =
action: 'choose_trade_type';
subform_name: 'info_old' | 'info_new';
form_name: string;
trade_type_name: string;
trade_type_name?: string;
}
| {
action: 'choose_trade_type';
subform_name: 'trade_type';
tab_name: string;
form_name: string;
trade_type_name: string;
trade_type_name?: string;
}
| {
action: 'search';
Expand All @@ -75,19 +121,22 @@ type TradeTypesFormAction =
| {
action: 'info_open';
tab_name: string;
trade_type_name: string;
trade_type_name?: string;
}
| {
action: 'info-switcher';
action: 'info_switcher';
info_switcher_mode: string;
trade_type_name: string;
trade_type_name?: string;
};

type IdentifyAction = {
language: string;
};

type TEvents = {
ce_chart_types_form: ChartTypesFormAction;
ce_indicators_types_form: IndicatorsTypesFormAction;
ce_market_types_form: MarketTypesFormAction;
ce_virtual_signup_form: VirtualSignupFormAction;
ce_real_account_signup_form: RealAccountSignupFormAction;
ce_virtual_signup_email_confirmation: VirtualSignupEmailConfirmationAction;
Expand All @@ -99,6 +148,7 @@ export class RudderStack {
has_identified = false;
has_initialized = false;
current_page = '';
account_type = '';

constructor() {
this.init();
Expand All @@ -123,6 +173,10 @@ export class RudderStack {
}
}

setAccountType(account_type: string) {
this.account_type = account_type;
}

identifyEvent = (user_id: string, payload: TEvents['identify']) => {
if (this.has_initialized) {
RudderAnalytics.identify(user_id, payload);
Expand Down Expand Up @@ -155,7 +209,10 @@ export class RudderStack {
*/
track<T extends keyof TEvents>(event: T, payload: TEvents[T]) {
if (this.has_initialized && this.has_identified) {
RudderAnalytics.track(event, payload);
RudderAnalytics.track(event, {
...payload,
account_type: this.account_type,
});
}
}
}
Expand Down
14 changes: 0 additions & 14 deletions packages/api/src/hooks/usePOIStatus.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/bot-skeleton/src/scratch/dbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class DBot {
this.workspace.addChangeListener(event => updateDisabledBlocks(this.workspace, event));
this.workspace.addChangeListener(event => this.workspace.dispatchBlockEventEffects(event));
this.workspace.addChangeListener(event => {
if (event.type === 'endDrag') validateErrorOnBlockDelete();
if (event.type === 'endDrag' && !is_mobile) validateErrorOnBlockDelete();
});

Blockly.derivWorkspace = this.workspace;
Expand Down
2 changes: 1 addition & 1 deletion packages/bot-skeleton/src/scratch/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const matchTranslateAttribute = translateString => {
};

export const extractTranslateValues = () => {
const transform_value = Blockly?.derivWorkspace?.trashcan.svgGroup_.getAttribute('transform');
const transform_value = Blockly?.derivWorkspace?.trashcan?.svgGroup_.getAttribute('transform');
const translate_xy = matchTranslateAttribute(transform_value);

if (!translate_xy) {
Expand Down
8 changes: 7 additions & 1 deletion packages/bot-web-ui/src/stores/quick-strategy-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ export default class QuickStrategyStore {

this.root_store = root_store;
}
selected_symbol: TMarketOption = (this.qs_cache.selected_symbol as TMarketOption) || {};
selected_symbol: TMarketOption =
(this.qs_cache.selected_symbol as TMarketOption) || {
group: 'Continuous Indices',
text: 'Volatility 100 Index',
value: 'R_100',
} ||
{};
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) || {};
Expand Down
Loading

0 comments on commit 018f1e9

Please sign in to comment.