import { useQuery } from "@tanstack/react-query";
import { queryKeys } from "./keys";
import { feesService } from "@/services/fees.service";
import type { PaginationParams } from "@/types";

export function useFeesPlans(params?: PaginationParams) {
  return useQuery({
    queryKey: queryKeys.feesPlans.list(params),
    queryFn: () => feesService.listFeesPlans(params),
  });
}

export function useFeesPlan(id: number) {
  return useQuery({
    queryKey: queryKeys.feesPlans.detail(id),
    queryFn: () => feesService.getFeesPlan(id),
    enabled: !!id,
  });
}

export function useStudentFees(params?: PaginationParams) {
  return useQuery({
    queryKey: queryKeys.studentFees.list(params),
    queryFn: () => feesService.listStudentFees(params),
  });
}

export function useFeesTerms(params?: PaginationParams) {
  return useQuery({
    queryKey: queryKeys.feesTerms.list(params),
    queryFn: () => feesService.listFeesTerms(params),
  });
}
