Skip to content

Commit 8f1d59f

Browse files
committed
Mint buttons prompt connect if necessary
1 parent d23f3d4 commit 8f1d59f

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/app/client.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
TextField,
2323
Theme,
2424
} from '@radix-ui/themes'
25-
import { useIsMounted } from 'connectkit'
25+
import { useIsMounted, useModal } from 'connectkit'
2626
import Link from 'next/link'
2727
import { usePathname, useRouter } from 'next/navigation'
2828
import { useCallback, useEffect, useState } from 'react'
@@ -44,6 +44,7 @@ export function HomeClientPage({ color: initialColor }: HomeClientPageProps) {
4444
const pathname = usePathname()
4545
const isMounted = useIsMounted()
4646
const { address } = useAccount()
47+
const { setOpen } = useModal()
4748

4849
const [color, setColor] = useState(initialColor)
4950
const [randomMintAmount, setRandomMintAmount] = useState(1)
@@ -212,10 +213,12 @@ export function HomeClientPage({ color: initialColor }: HomeClientPageProps) {
212213
<Button
213214
size="4"
214215
onClick={() =>
215-
mint({
216-
args: [color.r, color.g, color.b],
217-
value: parseEther('0.004'),
218-
})
216+
address
217+
? mint({
218+
args: [color.r, color.g, color.b],
219+
value: parseEther('0.004'),
220+
})
221+
: setOpen(true)
219222
}
220223
loading={mintPending}
221224
disabled={mintRandomPending || allowlistMintPending}
@@ -250,10 +253,12 @@ export function HomeClientPage({ color: initialColor }: HomeClientPageProps) {
250253
<Button
251254
size="4"
252255
onClick={() =>
253-
mintRandom({
254-
args: [randomMintAmount],
255-
value: parseEther(randomMintCost),
256-
})
256+
address
257+
? mintRandom({
258+
args: [randomMintAmount],
259+
value: parseEther(randomMintCost),
260+
})
261+
: setOpen(true)
257262
}
258263
loading={mintRandomPending}
259264
disabled={mintPending}

0 commit comments

Comments
 (0)