import { useQuery } from "@tanstack/react-query";
import recordAxiosInstance from "@/shared/services/recordAxiosInstance";

interface ReportStats {
  assigned: number;
  approved: number;
  pending: number;
  rejected: number;
  reassigned: number;
  replied: number;
}

interface IncomingReportData {
  [key: string]: ReportStats & Record<string, any>;
}

export const useIncomingReport = (positionId?: string) => {
  return useQuery({
    queryKey: ["incomingReport", positionId],
    queryFn: async () => {
      const response = await recordAxiosInstance.get<IncomingReportData>(
        "/reports/incoming-report",
        {
          headers: {
            ...(positionId && { "x-current-position-id": positionId }),
          },
        }
      );
      return response.data;
    },
    enabled: !!positionId,
    staleTime: 5 * 60 * 1000, // 5 minutes
  });
};
