import { useQuery } from '@tanstack/react-query'
import type { UseQueryOptions } from '@tanstack/react-query'
import { getMe } from '../api/profileApi'
import type { MeResponse } from '../api/profileApi'

type MeOptions = Pick<UseQueryOptions<MeResponse>, 'refetchInterval' | 'enabled'>

export function useMe(options?: MeOptions) {
  return useQuery<MeResponse>({
    queryKey: ['me'],
    queryFn: getMe,
    staleTime: Infinity,
    gcTime: Infinity,
    retry: false,
    ...options,
  })
}
