From 785c95dfd408238c4f0f7733795ddf5ae2cd16d6 Mon Sep 17 00:00:00 2001 From: jia-deriv Date: Fri, 28 Jun 2024 15:04:54 +0800 Subject: [PATCH 1/2] chore: update redirect link for partner signin and signup --- .../navigation/partners-nav/nav.buttons.tsx | 25 ++++++++++++++++--- .../src/pages/why-choose-us/index.tsx | 4 +-- .../src/store/region-context.tsx | 9 ++++++- .../gatsby-theme-deriv/src/types/generics.ts | 1 + 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/themes/gatsby-theme-deriv/src/features/components/templates/navigation/partners-nav/nav.buttons.tsx b/themes/gatsby-theme-deriv/src/features/components/templates/navigation/partners-nav/nav.buttons.tsx index da892d29bb8..c5bfc941d65 100644 --- a/themes/gatsby-theme-deriv/src/features/components/templates/navigation/partners-nav/nav.buttons.tsx +++ b/themes/gatsby-theme-deriv/src/features/components/templates/navigation/partners-nav/nav.buttons.tsx @@ -5,23 +5,42 @@ import { getLocationPathname } from 'common/utility' import { Localize, LocalizedLink } from 'components/localization' import useAffiliateSignupLink from 'features/hooks/ab-testing/use-partners-signup-link' import useBuildVariant from 'features/hooks/use-build-variant' +import useWebsiteStatus from 'components/hooks/use-website-status' const AffiliateButtons = () => { const { affiliate_signup_link } = useAffiliateSignupLink() + const { website_status } = useWebsiteStatus() + + const user_ip_country = website_status?.clients_country || '' + return ( <> @@ -60,7 +79,7 @@ const PartnersNavButtons = () => { }, [path_name]) useEffect(() => { - setShowPaymentBtns(path_name.includes('payment-agent') && region !== "eu") + setShowPaymentBtns(path_name.includes('payment-agent') && region !== 'eu') }, [region, path_name]) return ( diff --git a/themes/gatsby-theme-deriv/src/pages/why-choose-us/index.tsx b/themes/gatsby-theme-deriv/src/pages/why-choose-us/index.tsx index 08b4a73e93c..ad2a7121299 100644 --- a/themes/gatsby-theme-deriv/src/pages/why-choose-us/index.tsx +++ b/themes/gatsby-theme-deriv/src/pages/why-choose-us/index.tsx @@ -59,8 +59,8 @@ const ResponsiveHeader = styled(StyledHeader)` } ` -const WhyChooseUs = ({pageContext}: TGatsbyHead) => { - const {region} = pageContext +const WhyChooseUs = ({ pageContext }: TGatsbyHead) => { + const { region } = pageContext const { is_latam, is_africa } = useRegion() const handleSignup = useHandleSignup() diff --git a/themes/gatsby-theme-deriv/src/store/region-context.tsx b/themes/gatsby-theme-deriv/src/store/region-context.tsx index 237354654f8..e2c0d08169a 100644 --- a/themes/gatsby-theme-deriv/src/store/region-context.tsx +++ b/themes/gatsby-theme-deriv/src/store/region-context.tsx @@ -39,7 +39,8 @@ type RegionContextType = Record< | 'is_africa' | 'is_appgallery_supported' | 'is_appgallery_and_ios_supported' - | 'is_ios_supported', + | 'is_ios_supported' + | 'is_ghana', boolean > & { user_country: string } @@ -58,6 +59,7 @@ export const RegionProvider = ({ children }: RegionProviderProps) => { is_row: !isEuDomain(), is_dev: false, is_africa: false, + is_ghana: false, }) const [is_p2p_allowed_country, setP2PAllowedCountry] = useState(false) const [is_appgallery_supported, setAppgallerySupported] = useState(false) @@ -75,6 +77,8 @@ export const RegionProvider = ({ children }: RegionProviderProps) => { useEffect(() => { const is_eu_country_ip = eu_countries.includes(user_ip_country) + const is_ghana = user_ip_country === 'gh' || qa_url_region === 'gh' + debugger const is_africa = african_countries.includes(user_ip_country) || african_countries.includes(qa_url_region) const is_eu_residence = eu_countries.includes(residence) @@ -114,6 +118,7 @@ export const RegionProvider = ({ children }: RegionProviderProps) => { is_africa, is_row, is_dev, + is_ghana, }) } }, [residence, user_ip_country, website_status]) @@ -149,6 +154,7 @@ export const RegionProvider = ({ children }: RegionProviderProps) => { is_africa, is_row, is_dev, + is_ghana, } = region return ( @@ -169,6 +175,7 @@ export const RegionProvider = ({ children }: RegionProviderProps) => { is_appgallery_supported, is_appgallery_and_ios_supported, is_ios_supported, + is_ghana, }} > {children} diff --git a/themes/gatsby-theme-deriv/src/types/generics.ts b/themes/gatsby-theme-deriv/src/types/generics.ts index a401a2f6cc8..2f6f1393707 100644 --- a/themes/gatsby-theme-deriv/src/types/generics.ts +++ b/themes/gatsby-theme-deriv/src/types/generics.ts @@ -10,6 +10,7 @@ export type TRegion = { is_row: boolean is_dev: boolean is_africa: boolean + is_ghana: boolean } export type StringObjectType = { From 179f115675dad63ce0cf166949ce999b92f2905a Mon Sep 17 00:00:00 2001 From: jia-deriv Date: Fri, 28 Jun 2024 15:42:40 +0800 Subject: [PATCH 2/2] chore: cleanup code --- .../templates/navigation/partners-nav/nav.buttons.tsx | 5 +++-- themes/gatsby-theme-deriv/src/store/region-context.tsx | 9 +-------- themes/gatsby-theme-deriv/src/types/generics.ts | 1 - 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/themes/gatsby-theme-deriv/src/features/components/templates/navigation/partners-nav/nav.buttons.tsx b/themes/gatsby-theme-deriv/src/features/components/templates/navigation/partners-nav/nav.buttons.tsx index c5bfc941d65..dcde47b133a 100644 --- a/themes/gatsby-theme-deriv/src/features/components/templates/navigation/partners-nav/nav.buttons.tsx +++ b/themes/gatsby-theme-deriv/src/features/components/templates/navigation/partners-nav/nav.buttons.tsx @@ -12,6 +12,7 @@ const AffiliateButtons = () => { const { website_status } = useWebsiteStatus() const user_ip_country = website_status?.clients_country || '' + const is_gh = user_ip_country === 'gh' return ( <> @@ -21,7 +22,7 @@ const AffiliateButtons = () => { size="lg" onClick={() => window.open( - user_ip_country === 'my' + is_gh ? 'https://dynamicworks-dev.deriv.services/login?brd=1' : 'https://login.deriv.com/signin.php?lang=0', '_blank', @@ -35,7 +36,7 @@ const AffiliateButtons = () => { size="lg" onClick={() => window.open( - user_ip_country === 'my' + is_gh ? 'https://dynamicworks-dev.deriv.services/live_signup?brd=1' : affiliate_signup_link, '_blank', diff --git a/themes/gatsby-theme-deriv/src/store/region-context.tsx b/themes/gatsby-theme-deriv/src/store/region-context.tsx index e2c0d08169a..237354654f8 100644 --- a/themes/gatsby-theme-deriv/src/store/region-context.tsx +++ b/themes/gatsby-theme-deriv/src/store/region-context.tsx @@ -39,8 +39,7 @@ type RegionContextType = Record< | 'is_africa' | 'is_appgallery_supported' | 'is_appgallery_and_ios_supported' - | 'is_ios_supported' - | 'is_ghana', + | 'is_ios_supported', boolean > & { user_country: string } @@ -59,7 +58,6 @@ export const RegionProvider = ({ children }: RegionProviderProps) => { is_row: !isEuDomain(), is_dev: false, is_africa: false, - is_ghana: false, }) const [is_p2p_allowed_country, setP2PAllowedCountry] = useState(false) const [is_appgallery_supported, setAppgallerySupported] = useState(false) @@ -77,8 +75,6 @@ export const RegionProvider = ({ children }: RegionProviderProps) => { useEffect(() => { const is_eu_country_ip = eu_countries.includes(user_ip_country) - const is_ghana = user_ip_country === 'gh' || qa_url_region === 'gh' - debugger const is_africa = african_countries.includes(user_ip_country) || african_countries.includes(qa_url_region) const is_eu_residence = eu_countries.includes(residence) @@ -118,7 +114,6 @@ export const RegionProvider = ({ children }: RegionProviderProps) => { is_africa, is_row, is_dev, - is_ghana, }) } }, [residence, user_ip_country, website_status]) @@ -154,7 +149,6 @@ export const RegionProvider = ({ children }: RegionProviderProps) => { is_africa, is_row, is_dev, - is_ghana, } = region return ( @@ -175,7 +169,6 @@ export const RegionProvider = ({ children }: RegionProviderProps) => { is_appgallery_supported, is_appgallery_and_ios_supported, is_ios_supported, - is_ghana, }} > {children} diff --git a/themes/gatsby-theme-deriv/src/types/generics.ts b/themes/gatsby-theme-deriv/src/types/generics.ts index 2f6f1393707..a401a2f6cc8 100644 --- a/themes/gatsby-theme-deriv/src/types/generics.ts +++ b/themes/gatsby-theme-deriv/src/types/generics.ts @@ -10,7 +10,6 @@ export type TRegion = { is_row: boolean is_dev: boolean is_africa: boolean - is_ghana: boolean } export type StringObjectType = {