import { useQuery } from "@tanstack/react-query";
import { QUERY_KEYS } from "@/utils/query-key";
import {
  getDiscountUsageReport,
  getCustomerDiscountUsageReport,
} from "./_requests";
import {
  DiscountUsageFilters,
  CustomerDiscountUsageFilters,
} from "./_models";

export const useDiscountUsageReport = (filters: DiscountUsageFilters) => {
  return useQuery({
    queryKey: [QUERY_KEYS.GET_DISCOUNT_USAGE_REPORT, filters],
    queryFn: () => getDiscountUsageReport(filters),
    enabled: filters.limit > 0,
  });
};

export const useCustomerDiscountUsageReport = (
  filters: CustomerDiscountUsageFilters
) => {
  return useQuery({
    queryKey: [QUERY_KEYS.GET_CUSTOMER_DISCOUNT_USAGE_REPORT, filters],
    queryFn: () => getCustomerDiscountUsageReport(filters),
    enabled: filters.user_id > 0 && filters.limit > 0,
  });
};

