Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 3939ac2

Browse files
Urlhandling from derivgo (#2696)
* replaced financial disclosure report pdf with new one * handle urls frpm derivgo app * changes based on code review * variable name formating * add common function in to utility * improvement * empty commit to trigger build step * issue fix * updates based on fe review Co-authored-by: ashrafali-v <[email protected]>
1 parent e4a2ac7 commit 3939ac2

File tree

6 files changed

+34
-10
lines changed

6 files changed

+34
-10
lines changed

src/common/utility.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,3 +475,12 @@ export const handleRedirect = (subdomain, residence, current_client_country, ful
475475
handleDerivRedirect(country, subdomain)
476476
}
477477
}
478+
479+
export const queryParamData = () => {
480+
if (isBrowser()) {
481+
const queryParams = new URLSearchParams(window.location.search)
482+
const platform_name = queryParams.get('platform')
483+
const platform_list = ['derivgo', 'p2p']
484+
return platform_list.includes(platform_name) ? platform_name : ''
485+
} else return ''
486+
}

src/components/layout/layout.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ import { LocationProvider } from './location-context'
1111
import EURedirect, { useModal } from 'components/custom/_eu-redirect-modal.js'
1212
import CookieBanner from 'components/custom/cookie-banner'
1313
import { CookieStorage } from 'common/storage'
14-
import { isBrowser, handleRedirect } from 'common/utility'
14+
import { isBrowser, handleRedirect, queryParamData } from 'common/utility'
1515
import { DerivStore } from 'store'
1616
import { Localize } from 'components/localization'
1717
import { Text } from 'components/elements'
1818
import device from 'themes/device'
1919
import { Container } from 'components/containers'
2020
import { loss_percent } from 'common/constants'
2121
import { useWebsiteStatus } from 'components/hooks/use-website-status'
22-
2322
const Footer = Loadable(() => import('./footer'))
2423
const BeSquareFooter = Loadable(() => import('./besquare/footer'))
2524
const LiveChat = Loadable(() => import('./livechat'))
@@ -131,7 +130,6 @@ const Layout = ({
131130
const [gtm_data, setGTMData] = useGTMData()
132131

133132
const is_static = type === 'static'
134-
135133
// Allow tracking cookie banner setup
136134
React.useEffect(() => {
137135
if (typeof is_eu_country === 'boolean') {
@@ -236,7 +234,14 @@ const Layout = ({
236234
FooterNav = <Footer is_ppc={is_ppc} is_ppc_redirect={is_ppc_redirect} />
237235
break
238236
}
239-
237+
//Handle page layout when redirection from mobile app.
238+
if (queryParamData()) {
239+
return (
240+
<Main margin_top={'0'} is_static={is_static}>
241+
{children}
242+
</Main>
243+
)
244+
}
240245
return (
241246
<LocationProvider
242247
has_mounted={has_mounted}

src/pages/help-centre/_article-component.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type ArticleComponentProps = {
4040
all_categories: CategoryType
4141
toggleArticle: (arg: string) => void
4242
is_eu_country: boolean
43+
param: string
4344
}
4445

4546
const ArticleDiv = styled.div`
@@ -149,6 +150,7 @@ const ArticleComponent = ({
149150
all_categories,
150151
toggleArticle,
151152
is_eu_country,
153+
param,
152154
}: ArticleComponentProps) => {
153155
return (
154156
<ArticleDiv key={idx}>
@@ -176,6 +178,7 @@ const ArticleComponent = ({
176178
to={convertToHash(
177179
item.category.props.translate_text,
178180
label_type,
181+
param,
179182
)}
180183
>
181184
{title_type}

src/pages/help-centre/_article.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { localize } from 'components/localization'
77
import { SideTab, StyledLink } from 'components/elements'
88
import { Container, SEO } from 'components/containers'
99
import device from 'themes/device'
10-
10+
import { queryParamData } from 'common/utility'
1111
export type ArticleProps = {
1212
children?: React.ReactNode
1313
header?: string
@@ -36,6 +36,7 @@ const TabWrapper = styled.div`
3636
const ContactContainer = styled.div`
3737
margin-top: 8rem;
3838
`
39+
const platform = queryParamData()
3940
export const Article = ({
4041
children,
4142
header = '',
@@ -56,7 +57,7 @@ export const Article = ({
5657
/>
5758
<Container align="left" justify="flex-start" direction="column">
5859
<StyledLink
59-
to="/help-centre/"
60+
to={platform ? `/help-centre/?platform=${platform}` : '/help-centre/'}
6061
has_arrow="true"
6162
color="black"
6263
size="var(--text-size-s)"

src/pages/help-centre/_utility.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { ArcticlesType } from './_help-articles'
22

3-
export const convertToHash = (category: string, label: string): string => {
4-
return '/help-centre/' + category.replace(/\s/g, '-').toLowerCase() + '/#' + label
3+
export const convertToHash = (category, label, qparam) => {
4+
const categoryFormatter = category.replace(/\s/g, '-').toLowerCase()
5+
if (qparam) {
6+
return `/help-centre/${categoryFormatter}/?platform=${qparam}#${label}`
7+
} else {
8+
return `/help-centre/${categoryFormatter}/#${label}`
9+
}
510
}
611

712
export const getAllArticles = (articles: ArcticlesType[]) =>

src/pages/help-centre/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { SEO, Show, Container } from 'components/containers'
1111
import { Header } from 'components/elements'
1212
import Layout from 'components/layout/layout'
1313
import { localize, WithIntl } from 'components/localization'
14-
import { getLocationHash, sanitize } from 'common/utility'
14+
import { getLocationHash, sanitize, queryParamData } from 'common/utility'
1515
import { DerivStore } from 'store'
1616
import device from 'themes/device'
1717
// Icons
@@ -144,7 +144,7 @@ const ResponsiveHeader = styled(Header)`
144144
font-size: 4rem;
145145
}
146146
`
147-
147+
const param = queryParamData()
148148
const HelpCentre = () => {
149149
const { is_eu_country } = React.useContext(DerivStore)
150150
const [data, setData] = useState({
@@ -289,6 +289,7 @@ const HelpCentre = () => {
289289
all_categories={data.all_categories}
290290
toggleArticle={toggleArticle}
291291
is_eu_country={is_eu_country}
292+
param={param}
292293
/>
293294
)
294295
})}

0 commit comments

Comments
 (0)