-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TRAH5082] Suisin/trah5082/change traders hub button url based on ff (#…
…17916) * chore: open new tab for options and cfds in hub when user has wallets account * chore: only to add it in wallets account switcher * chore: fix build fail * chore: revert TContractInfo auto convert * chore: change to have redirection logic on tradershub page itself * chore: change taxResidence to citizen * chore: update redirection logic and add hooks for checking hub redirection * chore: revert auto correct TContractInfo * chore: revert AppContent and account-switcher-wallet logic * chore: if modal is open in tradershub we dont redirect user to low-code * chore: fix failing testcase and revert TContractInfo * chore: display blank screen in wallets for hub enabled countries * chore: fix build failing issue * chore: fix code based on comments * chore: update to use process.env.NODE_ENV based on comment * chore: update logic redirection to check either trading_hub or GB value is true * chore: fix redirection to staging-hub when clicking on cfds button * chore: fix redirection before clicking on Get started
- Loading branch information
1 parent
51811f7
commit 8664cb5
Showing
39 changed files
with
421 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { useIsMounted } from 'usehooks-ts'; | ||
|
||
import { getFeatureFlag } from '@deriv/utils'; | ||
import { Analytics } from '@deriv-com/analytics'; | ||
|
||
interface UseGrowthbookGetFeatureValueArgs<T> { | ||
featureFlag: string; | ||
defaultValue?: T; | ||
} | ||
|
||
const useGrowthbookGetFeatureValue = <T extends string | boolean>({ | ||
featureFlag, | ||
defaultValue, | ||
}: UseGrowthbookGetFeatureValueArgs<T>) => { | ||
const resolvedDefaultValue: T = defaultValue !== undefined ? defaultValue : (false as T); | ||
const [featureFlagValue, setFeatureFlagValue] = useState<boolean>(false); | ||
const [isGBLoaded, setIsGBLoaded] = useState(false); | ||
const isMounted = useIsMounted(); | ||
|
||
// Required for debugging Growthbook, this will be removed after this is added in the Analytics directly. | ||
if (typeof window !== 'undefined') { | ||
window.Analytics = Analytics; | ||
} | ||
|
||
useEffect(() => { | ||
const fetchFeatureFlag = async () => { | ||
const is_enabled = await getFeatureFlag(featureFlag, resolvedDefaultValue); | ||
if (isMounted()) { | ||
setFeatureFlagValue(is_enabled); | ||
setIsGBLoaded(true); | ||
} | ||
}; | ||
|
||
fetchFeatureFlag(); | ||
}, [featureFlag, resolvedDefaultValue, isMounted]); | ||
|
||
return [featureFlagValue, isGBLoaded]; | ||
}; | ||
|
||
export default useGrowthbookGetFeatureValue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import useClientCountry from './useClientCountry'; | ||
import useGrowthbookGetFeatureValue from './useGrowthbookGetFeatureValue'; | ||
import useSettings from './useSettings'; | ||
|
||
type THubEnabledCountryList = { | ||
hub_enabled_country_list: string[]; | ||
}; | ||
|
||
const useIsHubRedirectionEnabled = () => { | ||
const [hubEnabledCountryList] = useGrowthbookGetFeatureValue({ | ||
featureFlag: 'hub_enabled_country_list', | ||
}); | ||
const { data: clientCountry } = useClientCountry(); | ||
const { data: accountSettings } = useSettings(); | ||
const { citizen } = accountSettings; | ||
|
||
const isHubRedirectionEnabled = | ||
typeof hubEnabledCountryList === 'object' && | ||
hubEnabledCountryList !== null && | ||
Array.isArray((hubEnabledCountryList as THubEnabledCountryList).hub_enabled_country_list) && | ||
citizen && | ||
(hubEnabledCountryList as THubEnabledCountryList).hub_enabled_country_list.includes(citizen); | ||
|
||
const isChangingToHubAppId = | ||
typeof hubEnabledCountryList === 'object' && | ||
hubEnabledCountryList !== null && | ||
Array.isArray((hubEnabledCountryList as THubEnabledCountryList).hub_enabled_country_list) && | ||
clientCountry && | ||
(hubEnabledCountryList as THubEnabledCountryList).hub_enabled_country_list.includes(clientCountry); | ||
|
||
return { isHubRedirectionEnabled, isChangingToHubAppId }; | ||
}; | ||
|
||
export default useIsHubRedirectionEnabled; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.