Skip to content

Commit

Permalink
feat: redirect to deriv-app if the feature is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-hosseini-deriv committed Jul 31, 2024
1 parent 3154a1d commit f588c4a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Suspense } from 'react';
import { Suspense, useEffect } from 'react';
import { BrowserRouter } from 'react-router-dom';
import { QueryParamProvider } from 'use-query-params';
import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
Expand All @@ -7,13 +7,18 @@ import { useDerivAnalytics, useRedirectToOauth, useTrackjs } from '@/hooks';
import AppContent from '@/routes/AppContent';
import { initializeI18n, TranslationProvider } from '@deriv-com/translations';
import { Loader, useDevice } from '@deriv-com/ui';
import useGrowthbookGetFeatureValue from './hooks/custom-hooks/useGrowthbookGetFeatureValue';

const { VITE_CROWDIN_BRANCH_NAME, VITE_PROJECT_NAME, VITE_TRANSLATIONS_CDN_URL } = process.env;
const i18nInstance = initializeI18n({
cdnUrl: `${VITE_TRANSLATIONS_CDN_URL}/${VITE_PROJECT_NAME}/${VITE_CROWDIN_BRANCH_NAME}`,
});

const App = () => {
const [isP2PV2Enabled, isGBLoaded] = useGrowthbookGetFeatureValue({
defaultValue: false,
featureFlag: 'p2p_v2_enabled',
});
const { init: initTrackJS } = useTrackjs();
const { isDesktop } = useDevice();
const { redirectToOauth } = useRedirectToOauth();
Expand All @@ -23,6 +28,13 @@ const App = () => {
initDerivAnalytics();
redirectToOauth();

useEffect(() => {
if (isGBLoaded) {
if (!isP2PV2Enabled) {
window.location.href = 'https://app.deriv.com/cashier/p2p';
}
}
}, [isGBLoaded, isP2PV2Enabled]);
return (
<BrowserRouter>
{/* TODO: Replace the fallback element with the ErrorComponent */}
Expand Down

0 comments on commit f588c4a

Please sign in to comment.