import { useQuery } from '@tanstack/react-query';
import { pendingContributionsApi } from '../api/pending-contributions.api';

export function usePendingContributions(
  page: number = 1,
  pageSize: number = 20,
  contributionType?: string
) {
  return useQuery({
    queryKey: ['pending-contributions', 'list', page, pageSize, contributionType],
    queryFn: () => pendingContributionsApi.getList(page, pageSize, contributionType),
    staleTime: 30000,
  });
}

export function usePendingContributionsSummary() {
  return useQuery({
    queryKey: ['pending-contributions', 'summary'],
    queryFn: () => pendingContributionsApi.getSummary(),
    staleTime: 30000,
  });
}

export function useAllPendingMiningRecords(page: number = 1, pageSize: number = 20) {
  return useQuery({
    queryKey: ['pending-contributions', 'mining-records', 'all', page, pageSize],
    queryFn: () => pendingContributionsApi.getAllMiningRecords(page, pageSize),
    staleTime: 30000,
  });
}

export function usePendingContributionMiningRecords(
  id: string,
  page: number = 1,
  pageSize: number = 20
) {
  return useQuery({
    queryKey: ['pending-contributions', 'mining-records', id, page, pageSize],
    queryFn: () => pendingContributionsApi.getMiningRecords(id, page, pageSize),
    enabled: !!id,
    staleTime: 30000,
  });
}
