@@ -22,10 +22,11 @@ import {
2222 TextField ,
2323 Theme ,
2424} from '@radix-ui/themes'
25- import { useIsMounted } from 'connectkit'
25+ import { useIsMounted , useModal } from 'connectkit'
2626import Link from 'next/link'
2727import { usePathname , useRouter } from 'next/navigation'
2828import { useCallback , useEffect , useState } from 'react'
29+ import { toast } from 'sonner'
2930import useSWR from 'swr'
3031import { useEventListener } from 'usehooks-ts'
3132import { parseEther } from 'viem'
@@ -43,6 +44,7 @@ export function HomeClientPage({ color: initialColor }: HomeClientPageProps) {
4344 const pathname = usePathname ( )
4445 const isMounted = useIsMounted ( )
4546 const { address } = useAccount ( )
47+ const { setOpen } = useModal ( )
4648
4749 const [ color , setColor ] = useState ( initialColor )
4850 const [ randomMintAmount , setRandomMintAmount ] = useState ( 1 )
@@ -108,6 +110,11 @@ export function HomeClientPage({ color: initialColor }: HomeClientPageProps) {
108110 isPending : allowlistMintPending ,
109111 } = useWriteRgbSignaturesAllowlistMint ( )
110112
113+ useEffect ( ( ) => {
114+ if ( ! ( mintPending || mintRandomPending || allowlistMintPending ) ) return
115+ toast ( 'Please confirm in your wallet' , { position : 'bottom-right' } )
116+ } , [ mintPending , mintRandomPending , allowlistMintPending ] )
117+
111118 useEffect ( ( ) => {
112119 if ( ! mintHash && ! mintRandomHash && ! allowlistMintHash ) return
113120
@@ -206,10 +213,12 @@ export function HomeClientPage({ color: initialColor }: HomeClientPageProps) {
206213 < Button
207214 size = "4"
208215 onClick = { ( ) =>
209- mint ( {
210- args : [ color . r , color . g , color . b ] ,
211- value : parseEther ( '0.004' ) ,
212- } )
216+ address
217+ ? mint ( {
218+ args : [ color . r , color . g , color . b ] ,
219+ value : parseEther ( '0.004' ) ,
220+ } )
221+ : setOpen ( true )
213222 }
214223 loading = { mintPending }
215224 disabled = { mintRandomPending || allowlistMintPending }
@@ -244,10 +253,12 @@ export function HomeClientPage({ color: initialColor }: HomeClientPageProps) {
244253 < Button
245254 size = "4"
246255 onClick = { ( ) =>
247- mintRandom ( {
248- args : [ randomMintAmount ] ,
249- value : parseEther ( randomMintCost ) ,
250- } )
256+ address
257+ ? mintRandom ( {
258+ args : [ randomMintAmount ] ,
259+ value : parseEther ( randomMintCost ) ,
260+ } )
261+ : setOpen ( true )
251262 }
252263 loading = { mintRandomPending }
253264 disabled = { mintPending }
0 commit comments