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