Skip to content

Commit

Permalink
feat: added fetching ticket attestation data
Browse files Browse the repository at this point in the history
  • Loading branch information
mrisqid committed Aug 10, 2024
1 parent 594a011 commit bfbbf2f
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion apps/haus/src/app/ticket/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
'use client'
import { useEffect, useState } from 'react'
import { useAccount } from 'wagmi'
import Tickets from '@/components/tickets'

function TicketPage() {
return <Tickets />
const { address } = useAccount()
const [data, setData] = useState(null)
const [loading, setLoading] = useState(false)

useEffect(() => {
async function fetchData() {
try {
setLoading(true)
const response = await fetch(`/api/attestation?recipient=${address}`)
const result = await response.json()
setData(result)
} catch (error) {
console.error('Error fetching attestations:', error)
} finally {
setLoading(false)
}
}

if (address) {
fetchData()
}
}, [])

if (loading) return <>Loading...</>
return (
<>
<Tickets />
<pre>{JSON.stringify(data, null, 2)}</pre>
</>
)
}

export default TicketPage

0 comments on commit bfbbf2f

Please sign in to comment.