From 4ab26a34b6bb2842b5a86e965765b102adf1248b Mon Sep 17 00:00:00 2001 From: David maulana Date: Sat, 10 Aug 2024 15:33:56 +0700 Subject: [PATCH 1/3] check connection wallet --- apps/haus/src/components/event/index.tsx | 15 +++++++++++++-- apps/haus/src/components/provider/wagmi.ts | 14 +++++++------- apps/haus/src/components/wallet/index.tsx | 2 +- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/apps/haus/src/components/event/index.tsx b/apps/haus/src/components/event/index.tsx index c400dd6..59d65f9 100644 --- a/apps/haus/src/components/event/index.tsx +++ b/apps/haus/src/components/event/index.tsx @@ -9,21 +9,31 @@ import Button from '@mui/material/Button' import CardActions from '@mui/material/CardActions' import { useRouter } from 'next/navigation' import { Stack } from '@mui/material' +import { useAccount, useConnect } from 'wagmi' import LocationOnIcon from '@mui/icons-material/LocationOn' import EventIcon from '@mui/icons-material/Event' import { IEvent, formatPriceRange } from '@/utils/helper' +import { connectorCoinBaseWallet } from '../provider/wagmi' + interface EventProps { event: IEvent } export default function Event(props: EventProps) { const router = useRouter() + const { address } = useAccount() + const { connect } = useConnect() const { event } = props const handleClick = () => { - router.push(`/event/${event.id}`) + if (address) { + router.push(`/event/${event.id}`) + return + } + + connect({ connector: connectorCoinBaseWallet }) } return ( @@ -72,7 +82,8 @@ export default function Event(props: EventProps) {