import { useQuery } from '@tanstack/react-query';
import { paymentApi } from '@/lib/payment-api';

export const paymentKeys = {
  all: ['payments'] as const,
  transactions: (params: { status?: string; limit?: number; offset?: number }) =>
    ['payments', 'transactions', params] as const,
  status: (id: string) => ['payments', 'status', id] as const,
};

export function useTransactions(params: {
  status?: string;
  limit?: number;
  offset?: number;
} = {}) {
  return useQuery({
    queryKey: paymentKeys.transactions(params),
    queryFn: () => paymentApi.getTransactions(params),
  });
}

export function usePaymentStatus(id: string) {
  return useQuery({
    queryKey: paymentKeys.status(id),
    queryFn: () => paymentApi.getPaymentStatus(id),
    enabled: !!id,
  });
}
