import { useQuery, skipToken, UseBaseQueryOptions } from "@tanstack/react-query" import { useAuthApiClient } from "./useAuthApiClient" import { QUERY_KEYS } from "./constants" import { ONE_MINUTE_MS } from "../utils/time" import type { GetAccountByMezoIdOrAddressResponse } from "../api" export function useGetAccountByMezoId( mezoId?: string, queryOptions: Omit< UseBaseQueryOptions, "queryKey" | "queryFn" > = {}, ) { const authApiClient = useAuthApiClient() return useQuery({ queryKey: [QUERY_KEYS.ACCOUNT, mezoId], queryFn: mezoId ? () => authApiClient.getAccountByMezoIdOrAddress(mezoId) : skipToken, staleTime: ONE_MINUTE_MS, retry: 1, ...queryOptions, }) }