import { useQuery } from "@tanstack/react-query";
import type { UseQueryResult } from "@tanstack/react-query";
import { getPendingPartners, getMyAcceptances } from "../services/legal-api";
import type { PendingPartner, LegalAcceptance } from "../services/legal-api";

export const LEGAL_QUERY_KEYS = {
  pending: () => ["legal", "pending"] as const,
  myAcceptances: () => ["legal", "my-acceptances"] as const,
};

export const usePendingPartnersQuery = (
  enabled: boolean = true
): UseQueryResult<PendingPartner[]> => {
  return useQuery<PendingPartner[]>({
    queryKey: LEGAL_QUERY_KEYS.pending(),
    queryFn: getPendingPartners,
    enabled,
    staleTime: 5 * 60 * 1000, // 5 minutes stale time
  });
};

export const useMyAcceptancesQuery = (
  enabled: boolean = true
): UseQueryResult<LegalAcceptance[]> => {
  return useQuery<LegalAcceptance[]>({
    queryKey: LEGAL_QUERY_KEYS.myAcceptances(),
    queryFn: getMyAcceptances,
    enabled,
    staleTime: 5 * 60 * 1000,
  });
};
