Skip to content

Commit

Permalink
feat(sofi-referral): add migration handler back
Browse files Browse the repository at this point in the history
  • Loading branch information
mrodriguez-bc committed Jan 30, 2024
1 parent c83b8a1 commit 7697990
Showing 1 changed file with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
import React, { useEffect } from 'react'
import { RouteComponentProps } from 'react-router-dom'
import { useHistory, useLocation } from 'react-router-dom'

const SofiReferralComponent: React.FC = () => {
const location = useLocation()
const history = useHistory()

const SofiReferralComponent: React.FC<RouteComponentProps> = ({ location }) => {
useEffect(() => {
const searchParams = new URLSearchParams(location.search)
const viewParam = searchParams.get('buy')
const queryString = viewParam ? `?code=${viewParam}` : '?ref=sofi'
const hasAllRequiredJwtParams = ['aesCiphertext', 'aesIV', 'aesTag', 'aesKeyCiphertext'].every(
(param) => searchParams.has(param)
)

// if jwt is present, check the migration status

// if (hasAllRequiredJwtParams && migrationPending) {
if (hasAllRequiredJwtParams) {
history.push(`/sofi${location.search}`)
} else {
const viewParam = searchParams.get('buy')
const queryString = viewParam ? `?code=${viewParam}&ref=sofi` : '?ref=sofi'

window.location.href = `https://blockchainwallet.page.link/buysofi${queryString}`
}, [location])
window.location.href = `https://blockchainwallet.page.link/buysofi${queryString}`
}
}, [location, history])

return null
}
Expand Down

0 comments on commit 7697990

Please sign in to comment.