11import { useQuery } from "@tanstack/react-query" ;
2-
32import { useGraphqlBatcher } from "context/GraphqlBatcher" ;
4- import { isUndefined } from "utils/index" ;
5-
63import { graphql } from "src/graphql" ;
74import { JurorsByCoherenceScoreQuery } from "src/graphql/graphql" ;
8- export type { JurorsByCoherenceScoreQuery } ;
95
106const jurorsByCoherenceScoreQuery = graphql ( `
11- query JurorsByCoherenceScore($skip: Int, $first: Int, $orderBy: User_orderBy, $orderDirection: OrderDirection) {
7+ query JurorsByCoherenceScore(
8+ $skip: Int
9+ $first: Int
10+ $orderBy: User_orderBy
11+ $orderDirection: OrderDirection
12+ $search: String
13+ ) {
1214 users(
1315 first: $first
1416 skip: $skip
1517 orderBy: $orderBy
1618 orderDirection: $orderDirection
17- where: { totalResolvedVotes_gt: 0 }
19+ where: { totalResolvedVotes_gt: 0, userAddress_contains: $search }
1820 ) {
1921 id
2022 coherenceScore
@@ -25,26 +27,23 @@ const jurorsByCoherenceScoreQuery = graphql(`
2527 }
2628` ) ;
2729
28- export const useJurorsByCoherenceScore = ( skip = 0 , first = 20 , orderBy : string , orderDirection : string ) => {
29- const isEnabled = ! isUndefined ( first ) ;
30+ export const useJurorsByCoherenceScore = (
31+ skip = 0 ,
32+ first = 20 ,
33+ orderBy : string ,
34+ orderDirection : string ,
35+ search = ""
36+ ) => {
3037 const { graphqlBatcher } = useGraphqlBatcher ( ) ;
3138
3239 return useQuery < JurorsByCoherenceScoreQuery > ( {
33- queryKey : [ `JurorsByCoherenceScore` , skip , first , orderBy , orderDirection ] ,
34- enabled : isEnabled ,
40+ queryKey : [ "JurorsByCoherenceScore" , skip , first , orderBy , orderDirection , search ] ,
3541 staleTime : Infinity ,
3642 queryFn : async ( ) =>
37- isEnabled
38- ? await graphqlBatcher . fetch ( {
39- id : crypto . randomUUID ( ) ,
40- document : jurorsByCoherenceScoreQuery ,
41- variables : {
42- skip,
43- first,
44- orderBy,
45- orderDirection,
46- } ,
47- } )
48- : undefined ,
43+ await graphqlBatcher . fetch ( {
44+ id : crypto . randomUUID ( ) ,
45+ document : jurorsByCoherenceScoreQuery ,
46+ variables : { skip, first, orderBy, orderDirection, search } ,
47+ } ) ,
4948 } ) ;
5049} ;
0 commit comments