Skip to content

Commit

Permalink
Redirect to market after verification
Browse files Browse the repository at this point in the history
  • Loading branch information
IanPhilips committed Nov 27, 2024
1 parent d83b781 commit 9cb463f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
5 changes: 4 additions & 1 deletion web/components/bet/bet-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,10 @@ export const BuyPanelBody = (props: {
<Col className="gap-2">
{user ? (
shouldPromptVerification ? (
<VerifyButton content={<span>Verify to {TRADE_TERM}</span>} />
<VerifyButton
redirectHereAfterVerify
content={<span>Verify to {TRADE_TERM}</span>}
/>
) : (
<>
<LocationMonitor
Expand Down
5 changes: 4 additions & 1 deletion web/components/bet/limit-order-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,10 @@ export default function LimitOrderPanel(props: {
<Col className="gap-2">
{user ? (
shouldPromptVerification ? (
<VerifyButton content={<span>Verify to {TRADE_TERM}</span>} />
<VerifyButton
redirectHereAfterVerify
content={<span>Verify to {TRADE_TERM}</span>}
/>
) : (
<>
<LocationMonitor
Expand Down
7 changes: 5 additions & 2 deletions web/components/gidx/register-user-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export const RegisterUserForm = (props: {
const user = useUser() ?? props.user
const privateUser = usePrivateUser() ?? props.privateUser
const router = useRouter()
const { redirect } = router.query
const [page, setPage] = useState(
user.idVerified ||
user.kycDocumentStatus === 'pending' ||
Expand Down Expand Up @@ -96,7 +95,11 @@ export const RegisterUserForm = (props: {
useEffect(() => {
if (userSuccesfullyVerified) {
setTimeout(() => {
router.push('/checkout')
const { redirect } = router.query

// Get the redirect URL from query params, defaulting to /checkout
const redirectTo = redirect ?? '/checkout'
router.push(redirectTo as string)
}, TIME_TO_REDIRECT)
}
}, [userSuccesfullyVerified, router])
Expand Down
17 changes: 13 additions & 4 deletions web/components/sweeps/sweep-verify-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { CoinNumber } from '../widgets/coin-number'
import { Tooltip } from '../widgets/tooltip'
import { RainingCoins } from '../raining-coins'
import { SweepiesFlatCoin } from 'web/public/custom-components/sweepiesFlatCoin'
import { useRouter } from 'next/router'

export function SweepVerifySection(props: { className?: string }) {
const { className } = props
Expand Down Expand Up @@ -105,7 +106,10 @@ export function SweepVerifySection(props: { className?: string }) {
</div>

<Col className="gap-2">
<VerifyButton className=" !hover:from-amber-800 !hover:via-amber-700 !hover:to-amber-800 !mx-auto !w-fit !bg-gradient-to-r !from-amber-700 !via-amber-600 !to-amber-700 !text-white drop-shadow-lg" />
<VerifyButton
redirectHereAfterVerify
className=" !hover:from-amber-800 !hover:via-amber-700 !hover:to-amber-800 !mx-auto !w-fit !bg-gradient-to-r !from-amber-700 !via-amber-600 !to-amber-700 !text-white drop-shadow-lg"
/>

<Row className=" w-full">
<button
Expand Down Expand Up @@ -185,15 +189,20 @@ export function VerifyButton(props: {
className?: string
content?: ReactNode
color?: ColorType
redirectHereAfterVerify?: boolean
}) {
const { className, content, color } = props

const { className, content, color, redirectHereAfterVerify } = props
const router = useRouter()
const user = useUser()
const amount = useKYCGiftAmount(user)

return (
<Link
href={'/gidx/register'}
href={`/gidx/register${
redirectHereAfterVerify
? `?redirect=${encodeURIComponent(router.asPath)}`
: ''
}`}
className={clsx(
buttonClass('xl', color ?? 'gradient-pink'),
'w-full font-semibold',
Expand Down
2 changes: 1 addition & 1 deletion web/pages/checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const CheckoutPage = () => {
setError(null)
setLoading(true)
if (!user.idVerified) {
router.push('/gidx/register?redirect=checkout')
router.push('/gidx/register')
return
}
const { status, message } = getVerificationStatus(user, privateUser)
Expand Down

0 comments on commit 9cb463f

Please sign in to comment.