@@ -13,16 +13,17 @@ import { useLoggedInUser } from "@3rdweb-sdk/react/hooks/useLoggedInUser";
1313import { Turnstile } from "@marsidev/react-turnstile" ;
1414import { useMutation , useQuery , useQueryClient } from "@tanstack/react-query" ;
1515import type { CanClaimResponseType } from "app/api/testnet-faucet/can-claim/CanClaimResponseType" ;
16- import { Onboarding } from "components/onboarding" ;
1716import { mapV4ChainToV5Chain } from "contexts/map-chains" ;
1817import { useTrack } from "hooks/analytics/useTrack" ;
19- import { useState } from "react" ;
18+ import Link from "next/link" ;
19+ import { usePathname } from "next/navigation" ;
2020import { useForm } from "react-hook-form" ;
2121import { toast } from "sonner" ;
2222import { toUnits } from "thirdweb" ;
2323import type { ChainMetadata } from "thirdweb/chains" ;
2424import { useActiveAccount , useWalletBalance } from "thirdweb/react" ;
2525import { z } from "zod" ;
26+ import { isOnboardingComplete } from "../../../../../../login/isOnboardingRequired" ;
2627
2728function formatTime ( seconds : number ) {
2829 const rtf = new Intl . RelativeTimeFormat ( "en" , { numeric : "auto" } ) ;
@@ -52,6 +53,7 @@ export function FaucetButton({
5253 chain : ChainMetadata ;
5354 amount : number ;
5455} ) {
56+ const pathname = usePathname ( ) ;
5557 const client = useThirdwebClient ( ) ;
5658 const address = useActiveAccount ( ) ?. address ;
5759 const chainId = chain . chainId ;
@@ -118,7 +120,6 @@ export function FaucetButton({
118120
119121 const accountQuery = useAccount ( ) ;
120122 const userQuery = useLoggedInUser ( ) ;
121- const [ showOnboarding , setShowOnBoarding ] = useState ( false ) ;
122123
123124 const canClaimFaucetQuery = useQuery ( {
124125 queryKey : [ "testnet-faucet-can-claim" , chainId ] ,
@@ -145,7 +146,8 @@ export function FaucetButton({
145146 return (
146147 < CustomConnectWallet
147148 loginRequired = { true }
148- connectButtonClassName = "!w-full !rounded !bg-primary !text-primary-foreground !px-4 !py-2 !text-sm"
149+ loadingButtonClassName = "!w-full"
150+ signInLinkButtonClassName = "!w-full !h-auto !rounded !bg-primary !text-primary-foreground !px-4 !py-2 !text-sm hover:!bg-primary/80"
149151 />
150152 ) ;
151153 }
@@ -201,23 +203,17 @@ export function FaucetButton({
201203 ) ;
202204 }
203205
204- // Email verification is required to claim from the faucet
205- if (
206- ! accountQuery . data . emailConfirmedAt &&
207- ! accountQuery . data . unconfirmedEmail
208- ) {
206+ if ( ! isOnboardingComplete ( accountQuery . data ) ) {
209207 return (
210- < >
211- < Button
212- variant = "outline"
213- className = "!opacity-100 w-full "
214- onClick = { ( ) => setShowOnBoarding ( true ) }
208+ < Button asChild className = "w-full" >
209+ < Link
210+ href = {
211+ pathname ? `/login?next= ${ encodeURIComponent ( pathname ) } ` : "/login "
212+ }
215213 >
216214 Verify your Email
217- </ Button >
218- { /* We will show the modal only if the user click on it, because this is a public page */ }
219- { showOnboarding && < Onboarding onOpenChange = { setShowOnBoarding } /> }
220- </ >
215+ </ Link >
216+ </ Button >
221217 ) ;
222218 }
223219
0 commit comments