-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sofi-referral): create redirect handler for migration + anon ref…
…erral
- Loading branch information
1 parent
09e3e60
commit dc5c93b
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
packages/blockchain-wallet-v4-frontend/src/scenes/Refer/Sofi/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react' | ||
import { Redirect, RouteComponentProps } from 'react-router-dom' | ||
|
||
const SofiReferralComponent: React.FC<RouteComponentProps> = ({ location }) => { | ||
const searchParams = new URLSearchParams(location.search) | ||
const hasAllRequiredJwtParams = ['aesCiphertext', 'aesIV', 'aesTag', 'aesKeyCiphertext'].every( | ||
(param) => searchParams.has(param) | ||
) | ||
|
||
let redirectTo = '' | ||
if (hasAllRequiredJwtParams) { | ||
redirectTo = '/sofi' | ||
} else { | ||
redirectTo = 'https://blockchainwallet.page.link/buysofi' | ||
const viewParam = searchParams.get('buy') | ||
if (viewParam) { | ||
redirectTo += `?code=${viewParam}` | ||
} | ||
} | ||
|
||
redirectTo += location.search | ||
|
||
return <Redirect to={redirectTo} /> | ||
} | ||
|
||
export default SofiReferralComponent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters