import { api } from "@/lib/api-client";
import type { Lesson, LessonCreateRequest } from "@/types/lesson";
import type { PaginatedResponse, PaginationParams, ApiSuccessResponse } from "@/types";

export const lessonService = {
  async listLessons(params?: PaginationParams): Promise<PaginatedResponse<Lesson>> {
    return api.get<PaginatedResponse<Lesson>>("/lessons", params as Record<string, string | number | boolean | undefined>);
  },

  async createLesson(data: LessonCreateRequest): Promise<Lesson> {
    return api.post<Lesson>("/lessons", data);
  },

  async updateLesson(id: number, data: Partial<LessonCreateRequest>): Promise<Lesson> {
    return api.patch<Lesson>(`/lessons/${id}`, data);
  },

  async deleteLesson(id: number): Promise<ApiSuccessResponse> {
    return api.delete<ApiSuccessResponse>(`/lessons/${id}`);
  },
};
