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-engine/dashboard"),

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

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

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

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

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