import { useQuery } from "@tanstack/react-query";
import {
  getUnitReport,
  type UnitReport,
} from "@/super-admin/services/api/dashboardApi";

export const useUnitReport = (
  organizationId: string,
  unitId: string,
  options?: { enabled?: boolean },
) =>
  useQuery<UnitReport>({
    queryKey: ["unitReport", organizationId, unitId],
    queryFn: async () => {
      const { data } = await getUnitReport(organizationId, unitId);
      return data;
    },
    enabled:
      (options?.enabled ?? true) && !!organizationId && !!unitId,
    staleTime: 5 * 60 * 1000,
  });
