import { useQuery } from '@tanstack/react-query'
import { getPokemon, fetchPokemonFamilies } from '../api/pokemon'

export function usePokemon(id: number | null) {
  return useQuery({
    queryKey: ['pokemon', id],
    queryFn: () => getPokemon(id!),
    enabled: id !== null,
  })
}

export function usePokemonFamilies() {
  return useQuery({
    queryKey: ['pokemon', 'families'],
    queryFn: fetchPokemonFamilies,
    staleTime: Infinity,
  })
}
