Skip to content

Commit

Permalink
Merge pull request #27 from behnaz-deriv/test
Browse files Browse the repository at this point in the history
behnaz/referrer affiliate token
  • Loading branch information
habib-deriv authored Sep 12, 2024
2 parents 0397f76 + 94ebfae commit cf8a53d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Moreover, having these extensions will help you to speed up the development proc
2. **Clone using SSH**

```sh
git clone [email protected]:your-github-username/deriv-com.git
git clone [email protected]:your-github-username/signup-deriv-com.git
```

3. **Enter project directory**
Expand Down
12 changes: 12 additions & 0 deletions themes/gatsby-theme-deriv/src/common/url-affiliate-token.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

import { isBrowser } from './utility'
export const affiliateTokenURL = () => {
if (!isBrowser()) return;
const urlObject = new URL(window.location.href);
const params = new URLSearchParams(urlObject.search);
const token = params.get("t");
if (params.has("referrer") && token != null)
return token
}


Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type AffiliateAccountTypes = {
tnc_affiliate_accepted: boolean
promote_eu: boolean
}
referrer_token: string;
}
type AffiliateSendTypes = {
address_city: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import AtomicContainer from 'features/components/atoms/container'
import { TGatsbyHead } from 'features/types'
import device from 'themes/device'
import Map from 'images/common/affiliate/map.png'

import Cookies from 'js-cookie'
import { affiliateTokenURL } from 'common/url-affiliate-token'
const meta_attributes: TMetaAttributes = {
og_title: '_t_Partner Signup Page | Deriv_t_',
og_description:
Expand Down Expand Up @@ -48,6 +49,8 @@ const StyledContainer = styled(Container)`
`

const AffiliateSignup = ({ pageContext }: TGatsbyHead) => {
const aff_token_cookie = Cookies.getJSON("referrer_token")
const aff_token_url = affiliateTokenURL()
const { region } = pageContext
const [show_wizard, setShowWizard] = useState<boolean>(false)
const [is_online, setIsOnline] = useState(isBrowser() && navigator.onLine)
Expand Down Expand Up @@ -82,6 +85,7 @@ const AffiliateSignup = ({ pageContext }: TGatsbyHead) => {
tnc_affiliate_accepted: false,
promote_eu: false,
},
referrer_token: aff_token_cookie ?? aff_token_url ?? undefined,
})

const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export const Submit = ({
company_registration_number:
affiliate_account.account_details?.company_registration_number.trim(),
}),
...(affiliate_account.referrer_token && {
referrer_token: affiliate_account.referrer_token,
}),
})
}

Expand Down

0 comments on commit cf8a53d

Please sign in to comment.