Skip to content

Commit

Permalink
Merge branch 'deriv-com:main' into shontzu/TRAH-3015/ui-for-seamless-…
Browse files Browse the repository at this point in the history
…MT5-mobile-login-integration
  • Loading branch information
shontzu-deriv authored Apr 22, 2024
2 parents 2755dc7 + 285f655 commit 4e9c950
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-and-deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ jobs:
project_name: "traders-hub"
branch_name: staging
output_dir: dist
env:
RUDDERSTACK_KEY: ${{ vars.VITE_RUDDERSTACK_KEY }}
2 changes: 2 additions & 0 deletions .github/workflows/build-and-deploy-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ jobs:
project_name: "traders-hub"
branch_name: "pr-${{github.event.number}}"
output_dir: dist
env:
RUDDERSTACK_KEY: ${{ vars.VITE_RUDDERSTACK_KEY }}

- name: "Generate preview link comment"
uses: "deriv-com/shared-actions/.github/actions/post_preview_link_comment@v1"
Expand Down
23 changes: 19 additions & 4 deletions package-lock.json

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

9 changes: 8 additions & 1 deletion src/cfd/screens/Jurisdiction/JurisdictionScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { twMerge } from 'tailwind-merge';

import { Jurisdiction } from '@cfd/constants';

import { useAvailableMT5Accounts, useMT5AccountsList } from '@/hooks';
import { useAvailableMT5Accounts, useMT5AccountsList, useQueryParams } from '@/hooks';
import { useCFDContext, useDynamicLeverageModalState } from '@/providers';

import { JurisdictionCard } from './JurisdictionCard';
Expand All @@ -14,6 +14,7 @@ type TJurisdictionScreenProps = {

export const JurisdictionScreen = ({ setIsCheckBoxChecked }: TJurisdictionScreenProps) => {
const { cfdState, setCfdState } = useCFDContext();
const { closeModal } = useQueryParams();
const { data: availableMT5Accounts } = useAvailableMT5Accounts();
const { data: mt5AccountsList } = useMT5AccountsList();
const { marketType, selectedJurisdiction } = cfdState;
Expand All @@ -37,6 +38,12 @@ export const JurisdictionScreen = ({ setIsCheckBoxChecked }: TJurisdictionScreen
setIsCheckBoxChecked(false);
}, [selectedJurisdiction, setIsCheckBoxChecked]);

useEffect(() => {
if (typeof closeModal === 'function') {
setCfdState({ selectedJurisdiction: '' });
}
}, [closeModal, setCfdState]);

return (
<div
className={twMerge(
Expand Down
53 changes: 46 additions & 7 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,72 @@
import React from 'react';
import React, { useEffect } from 'react';
import ReactDOM from 'react-dom/client';

import { AppDataProvider } from '@deriv-com/api-hooks';
// eslint-disable-next-line import/no-extraneous-dependencies
import { Analytics } from '@deriv-com/analytics';
import { AppDataProvider, useWebsiteStatus } from '@deriv-com/api-hooks';
import { useDevice } from '@deriv-com/ui';
import { WebSocketUtils } from '@deriv-com/utils';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';

import { CFDProvider, RealAccountCreationProvider, UIProvider } from '@/providers';
import { startInitPerformanceTimers } from '@/utils';

import { Header } from './components/Header/Header.tsx';
import App from './App.tsx';
import { Header } from './components/Header/Header';
import { useActiveDerivTradingAccount } from './hooks/useActiveDerivTradingAccount';
import App from './App';

import './index.css';

const queryClient = new QueryClient();

// function to start the timer for login/signup/redirect
const AnalyticsConfigurator = () => {
const { data: activeTradingAccount } = useActiveDerivTradingAccount();
const { data: websiteStatusData } = useWebsiteStatus();
const { isDesktop, isMobile, isTablet } = useDevice();
const { getAppId } = WebSocketUtils;

useEffect(() => {
if (websiteStatusData?.clients_country) {
const accountType = activeTradingAccount?.is_virtual ? 'demo' : 'real';
const clientCountry = websiteStatusData.clients_country;

if (import.meta.env.VITE_RUDDERSTACK_KEY) {
const config = {
rudderstackKey: import.meta.env.VITE_RUDDERSTACK_KEY,
};
Analytics.initialise(config);
const attributes = {
account_type: accountType,
app_id: getAppId(),
device_type:
(isDesktop && 'Desktop') || (isMobile && 'Mobile') || (isTablet && 'Tablet') || 'Mobile',
device_language: navigator.language || 'en-EN',
user_language: 'en-EN',
country: clientCountry,
};
Analytics.setAttributes(attributes);
}
}
}, [activeTradingAccount, websiteStatusData]);

return null;
};

const container = document.getElementById('root');
const root = container ? ReactDOM.createRoot(container) : null;
startInitPerformanceTimers();

ReactDOM.createRoot(document.getElementById('root')!).render(
root?.render(
<React.StrictMode>
<QueryClientProvider client={queryClient}>
<AppDataProvider>
<UIProvider>
<CFDProvider>
<RealAccountCreationProvider>
{/* Temporary Header */}
<Header />
<App />
<AnalyticsConfigurator />
</RealAccountCreationProvider>
</CFDProvider>
</UIProvider>
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"types": ["@testing-library/jest-dom"],
"types": ["node", "@testing-library/jest-dom"],
"paths": {
"@/*": ["./src/*"],
"@cfd/*": ["./src/cfd/*"]
Expand Down

0 comments on commit 4e9c950

Please sign in to comment.