fix: th redirect issue #446
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces several changes across multiple files to enhance functionality related to user country management, redirection logic, and Traders Hub links. The most significant updates include storing the user's country in
localStorage
, improving redirection logic based on the user's country, and refactoring theTradershubLink
component to handle dynamic URLs.User Country Management:
authorize.country
) inlocalStorage
in bothAuthWrapper.tsx
andAPIBase
to make the country accessible across the application. ([[1]](https://github.com/deriv-com/bot/pull/446/files#diff-af63e738f04e9a6ee6aa4a007406f027572f6c9ba0d97b9dadc0f2e36d13521aR56)
,[[2]](https://github.com/deriv-com/bot/pull/446/files#diff-3b0931891357dd6358fa53dcd1ab528d4de6ec5e344c41956adbe694df9e4c89R187)
)clearAuthData
inauth-utils.ts
to remove theclient.country
entry fromlocalStorage
when clearing authentication data. ([src/utils/auth-utils.tsR15](https://github.com/deriv-com/bot/pull/446/files#diff-5ba545d290df6d6cdf65aeaa975c1a298851237b32144775e3468703ea548743R15)
)Redirection Logic:
shouldRedirectToTraderHub
intraders-hub-redirect.ts
to check if the user's country is in the enabled list from GrowthBook before redirecting. This ensures that redirection to the Traders Hub is country-specific. ([src/utils/traders-hub-redirect.tsL81-L84](https://github.com/deriv-com/bot/pull/446/files#diff-9e7ebbfc33380b8cdf202af9e5245d86a38c208dc40653c168d120e0d4dd8100L81-L84)
)Traders Hub Link Refactoring:
TradershubLink
component inmenu-items.tsx
to useuseState
anduseEffect
for dynamically setting the redirection URL based on the user's wallet status and virtual account status. ([[1]](https://github.com/deriv-com/bot/pull/446/files#diff-dc0c6cabb80e41effb7d5b0d9206c0bc3325309eb780758d24a71edb434360b5R90-R95)
,[[2]](https://github.com/deriv-com/bot/pull/446/files#diff-dc0c6cabb80e41effb7d5b0d9206c0bc3325309eb780758d24a71edb434360b5L103)
)href
attribute of theMenuItem
to useundefined
as a fallback when the redirection URL is null, improving robustness. ([src/components/layout/header/menu-items/menu-items.tsxL128-R133](https://github.com/deriv-com/bot/pull/446/files#diff-dc0c6cabb80e41effb7d5b0d9206c0bc3325309eb780758d24a71edb434360b5L128-R133)
)