import { useQuery } from "@tanstack/react-query";
import type { UseQueryResult } from "@tanstack/react-query";
import { getPartners } from "../services/auth-api";
import type { Partner } from "../services/auth-api";

export const PARTNERS_QUERY_KEYS = {
  list: () => ["partners", "list"] as const,
};

export const usePartnersQuery = (
  enabled: boolean = true
): UseQueryResult<Partner[]> => {
  return useQuery<Partner[]>({
    queryKey: PARTNERS_QUERY_KEYS.list(),
    queryFn: getPartners,
    enabled,
    staleTime: 5 * 60 * 1000, // 5 minutes stale time
  });
};
