From a7adce89cb1780dab42dd46bcf7475957614485f Mon Sep 17 00:00:00 2001 From: mrodriguez-bc Date: Tue, 30 Jan 2024 12:43:57 -0500 Subject: [PATCH] feat(sofi-referral): add migration handler back --- .../src/scenes/Refer/Sofi/index.tsx | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/packages/blockchain-wallet-v4-frontend/src/scenes/Refer/Sofi/index.tsx b/packages/blockchain-wallet-v4-frontend/src/scenes/Refer/Sofi/index.tsx index 9aa224159cf..b62ba50f604 100644 --- a/packages/blockchain-wallet-v4-frontend/src/scenes/Refer/Sofi/index.tsx +++ b/packages/blockchain-wallet-v4-frontend/src/scenes/Refer/Sofi/index.tsx @@ -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 = ({ 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 }