import { useQuery } from '@tanstack/react-query';
import { paymentApi } from '../apis';
import { paymentKeys } from '../keys';
import { CHECKOUT_SUMMARY_STALE_TIME } from '../constants';

/**
 * The customer's card payment history (wallet «پرداخت‌ها» tab, REQ-047). BNPL rows are sourced separately
 * from `services/bnpl`'s wallet installments — the two domains stay independent seams; the wallet screen
 * merges them for display.
 */
export function usePaymentHistory() {
  return useQuery({
    queryKey: paymentKeys.history(),
    queryFn: () => paymentApi.getPaymentHistory(),
    staleTime: CHECKOUT_SUMMARY_STALE_TIME,
  });
}
