Skip to content

Commit a7adce8

Browse files
committed
feat(sofi-referral): add migration handler back
1 parent c83b8a1 commit a7adce8

File tree

1 file changed

+20
-6
lines changed
  • packages/blockchain-wallet-v4-frontend/src/scenes/Refer/Sofi

1 file changed

+20
-6
lines changed

packages/blockchain-wallet-v4-frontend/src/scenes/Refer/Sofi/index.tsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
import React, { useEffect } from 'react'
2-
import { RouteComponentProps } from 'react-router-dom'
2+
import { useHistory, useLocation } from 'react-router-dom'
3+
4+
const SofiReferralComponent: React.FC = () => {
5+
const location = useLocation()
6+
const history = useHistory()
37

4-
const SofiReferralComponent: React.FC<RouteComponentProps> = ({ location }) => {
58
useEffect(() => {
69
const searchParams = new URLSearchParams(location.search)
7-
const viewParam = searchParams.get('buy')
8-
const queryString = viewParam ? `?code=${viewParam}` : '?ref=sofi'
10+
const hasAllRequiredJwtParams = ['aesCiphertext', 'aesIV', 'aesTag', 'aesKeyCiphertext'].every(
11+
(param) => searchParams.has(param)
12+
)
13+
14+
// if jwt is present, check the migration status
15+
16+
// if (hasAllRequiredJwtParams && migrationPending) {
17+
if (hasAllRequiredJwtParams) {
18+
history.push(`/sofi${location.search}`)
19+
} else {
20+
const viewParam = searchParams.get('buy')
21+
const queryString = viewParam ? `?code=${viewParam}&ref=sofi` : '?ref=sofi'
922

10-
window.location.href = `https://blockchainwallet.page.link/buysofi${queryString}`
11-
}, [location])
23+
window.location.href = `https://blockchainwallet.page.link/buysofi${queryString}`
24+
}
25+
}, [location, history])
1226

1327
return null
1428
}

0 commit comments

Comments
 (0)