import { api } from "@/lib/api-client";
import type { ExamSession, ExamAutoSave, ExamSubmitResponse } from "@/types";
import type { ApiSuccessResponse } from "@/types";

export const examSessionService = {
  getSession: (examId: number) =>
    api.get<ExamSession>(`/exam/${examId}/session`),

  autoSave: (examId: number, data: ExamAutoSave) =>
    api.post<ApiSuccessResponse>(`/exam/${examId}/autosave`, data),

  submit: (examId: number) =>
    api.post<ExamSubmitResponse>(`/exam/${examId}/submit`),

  getStatus: (examId: number) =>
    api.get<{ status: string; scores_available: boolean }>(`/exam/${examId}/status`),
};
