Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
Sergei / Add redirect_from query param (#7456)
Browse files Browse the repository at this point in the history
* feat: add redirect_from query param

* chore: empty

* feat: add util function to add query param
  • Loading branch information
sergei-deriv authored Apr 9, 2024
1 parent 58bf14f commit f20ccc1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
11 changes: 9 additions & 2 deletions themes/gatsby-theme-deriv/src/common/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,9 @@ export const useCallbackRef = (callback: () => void) => {

const getSubdomain = () => isBrowser() && window.location.hostname.split('.')[0]

export const isEuDomain = () => !!eu_domains.some((eu_sub_domain) => eu_sub_domain.test(getSubdomain()))

export const isEuDomain = () =>
!!eu_domains.some((eu_sub_domain) => eu_sub_domain.test(getSubdomain()))

export const isLocalhost = () => !!(isBrowser() && process.env.NODE_ENV === 'development')

export const isTestlink = () =>
Expand Down Expand Up @@ -455,3 +456,9 @@ export const getP2PCookie = () => {
const p2p_validity = Cookies.get('is_p2p_disabled')
return p2p_validity
}

export const addQueryParam = (link: string, param: string, value: string) => {
const url = new URL(link)
url.searchParams.set(param, value)
return url.toString()
}
10 changes: 8 additions & 2 deletions themes/gatsby-theme-deriv/src/components/custom/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { deriv_app_url } from 'common/constants'
import { getDerivAppLocalizedURL, getLanguage, redirectToTradingPlatform } from 'common/utility'
import {
addQueryParam,
getDerivAppLocalizedURL,
getLanguage,
redirectToTradingPlatform,
} from 'common/utility'

export const handleGetTrading = () => {
const sub_url = redirectToTradingPlatform()
Expand All @@ -15,5 +20,6 @@ export const handleRedirectToTradersHub = () => {
`${deriv_app_url}/appstore/traders-hub`,
getLanguage(),
)
window.location.href = trading_hub_url_localized
const redirect_link = addQueryParam(trading_hub_url_localized, 'redirect_from', 'deriv_com')
window.location.href = redirect_link
}

0 comments on commit f20ccc1

Please sign in to comment.