import { useQuery, type UseQueryResult } from '@tanstack/react-query';
import { fetchContacts } from '@/api/contacts';
import type { Contact } from '@/types';
import { STALE_TIME } from './refreshConfig';

export function useContacts(deviceId?: string): UseQueryResult<Contact[]> {
  return useQuery({
    queryKey: ['contacts', deviceId ?? null],
    queryFn: () => fetchContacts(deviceId),
    staleTime: STALE_TIME,
  });
}
