import { api } from "@/lib/api-client";
import type {
  GradingQueueItem,
  StudentResponse,
  RubricCriteria,
  AIGradeSuggestion,
  GradeSubmission,
} from "@/types";
import type { ApiSuccessResponse } from "@/types";

export const gradingService = {
  getQueue: (params?: { skill?: string; status?: string; exam_id?: number }) =>
    api.get<GradingQueueItem[]>("/grading/queue", params as Record<string, string | number | boolean | undefined>),

  getStudentResponse: (attemptId: number, skill: string) =>
    api.get<StudentResponse>(`/grading/${attemptId}/response`, { skill }),

  getRubric: (attemptId: number, skill: string) =>
    api.get<RubricCriteria[]>(`/grading/${attemptId}/rubric`, { skill }),

  getAISuggestion: (attemptId: number, skill: string) =>
    api.post<AIGradeSuggestion>("/grading/ai-suggest", { attempt_id: attemptId, skill }),

  submitGrade: (data: GradeSubmission) =>
    api.post<ApiSuccessResponse>(`/grading/${data.attempt_id}/submit`, data),
};
