import { api } from "@/lib/api-client";
import type {
  AdaptiveDashboardMetrics,
  AdaptiveEngineStudentRow,
  AdaptiveThresholdSettings,
  StudentAbilityModel,
  StudentAdaptiveSignal,
} from "@/types";
import type { ApiSuccessResponse } from "@/types";

export const adaptiveEngineService = {
  getDashboard: () => api.get<AdaptiveDashboardMetrics>("/adaptive/dashboard"),

  getStudents: (params?: { page?: number; limit?: number }) =>
    api.get<{ data: AdaptiveEngineStudentRow[]; pagination?: { total: number; page: number } }>(
      "/adaptive/students",
      params as Record<string, string | number | boolean | undefined>,
    ),

  getStudentSignals: (studentId: number) =>
    api.get<StudentAdaptiveSignal[]>(`/adaptive/student/${studentId}/signals`),

  getStudentAbility: (studentId: number) =>
    api.get<StudentAbilityModel>(`/adaptive/student/${studentId}/ability`),

  getSettings: () => api.get<AdaptiveThresholdSettings>("/adaptive/settings"),

  updateSettings: (data: AdaptiveThresholdSettings) =>
    api.put<ApiSuccessResponse>("/adaptive/settings", data),
};
