import { api } from "@/lib/api-client";
import type {
  AICourseConfig,
  QualityGateResult,
  IELTSValidationResult,
  ExaminerReview,
  AICourseTrack,
} from "@/types";
import type { ApiSuccessResponse } from "@/types";

export const aiCourseService = {
  createEnglish: (data: { current_level: string; target_level: string; learning_style: string[] }) =>
    api.post<{ course_id: number }>("/ai-course/english/create", data),

  createIelts: (data: { exam_type: string; target_band: number; skills: string[] }) =>
    api.post<{ course_id: number }>("/ai-course/ielts/create", data),

  getCourse: (courseId: number) =>
    api.get<AICourseConfig>(`/ai-course/${courseId}`),

  getTracks: (courseId: number) =>
    api.get<AICourseTrack[]>(`/ai-course/${courseId}/tracks`),

  getQualityGate: (courseId: number) =>
    api.get<QualityGateResult>(`/ai-course/${courseId}/quality`),

  approveQuality: (courseId: number) =>
    api.post<ApiSuccessResponse>(`/ai-course/${courseId}/quality/approve`),

  rejectQuality: (courseId: number, notes: string) =>
    api.post<ApiSuccessResponse>(`/ai-course/${courseId}/quality/reject`, { notes }),

  getIeltsValidation: (courseId: number) =>
    api.get<IELTSValidationResult>(`/ai-course/${courseId}/validation`),

  submitExaminerReview: (data: ExaminerReview) =>
    api.post<ApiSuccessResponse>(`/ai-course/examiner-review`, data),

  getEnglishTaxonomy: () =>
    api.get<Record<string, unknown>>("/ai-course/english/taxonomy"),
};
