feat: listings view with useListings hook and table
This commit is contained in:
17
app/src/hooks/useListings.ts
Normal file
17
app/src/hooks/useListings.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useCluster } from '@solana/connector/react'
|
||||
import { createSolanaRpc } from '@solana/kit'
|
||||
import { fetchAllListings } from '@solisting/sdk'
|
||||
|
||||
export function useListings() {
|
||||
const { cluster } = useCluster()
|
||||
return useQuery({
|
||||
queryKey: ['listings', cluster?.id],
|
||||
queryFn: () => {
|
||||
const rpc = createSolanaRpc(cluster!.url)
|
||||
return fetchAllListings(rpc)
|
||||
},
|
||||
enabled: !!cluster,
|
||||
refetchInterval: 30_000,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user