import { useQuery } from '@tanstack/react-query';
import { reportScore } from '@/lib/dashboard/dashboard-api';
import { mapReportScoreToCards } from '@/utils/map-report-score-to-cards';

export const useCreditFactors = (
  customerId: string | number,
  bureau: 'transunion' | 'equifax' | 'experian'
) => {
  return useQuery({
    queryKey: ['credit-factors', customerId, bureau],
    queryFn: async () => {
      const res = await reportScore(customerId, bureau);
      return mapReportScoreToCards(res);
    },
    staleTime: 1000 * 60 * 5,
  });
};
