import { useQuery } from '@tanstack/react-query';
import { bnplApi } from '../apis';
import { bnplKeys } from '../keys';
import { BNPL_WALLET_STALE_TIME } from '../constants';

/**
 * D5 — the customer's active installment plans, **provider-reported** (outstanding balance, next due date,
 * per-installment due list). Moderate `staleTime`: a plan does not change second-to-second, and it is
 * invalidated on settlement. This is a **read of provider status**, never a Balinyaar-managed ledger —
 * "early pay" hands off to the provider (D5), it is not a Balinyaar transaction.
 */
export function useWalletInstallments() {
  return useQuery({
    queryKey: bnplKeys.walletInstallments(),
    queryFn: () => bnplApi.getWalletInstallments(),
    staleTime: BNPL_WALLET_STALE_TIME,
  });
}
