export const api = {
  auth: {
    login: (data: { account: string; password: string }) => http.post('/auth/login', data),
    register: (data: { phone?: string; email?: string; password: string; nickname?: string }) => http.post('/auth/register', data),
    refresh: (accessToken: string) => http.post('/auth/refresh', { accessToken }),
    profile: () => http.get('/auth/profile'),
  },

  courses: {
    list: (params?: any) => http.get('/courses', params),
    detail: (id: number) => http.get(`/courses/${id}`),
    myLearning: () => http.get('/courses/my-learning'),
    updateProgress: (courseId: number, lessonId: number, data: any) =>
      http.post(`/courses/${courseId}/lessons/${lessonId}/progress`, data),
  },

  prompts: {
    list: (params?: any) => http.get('/prompts', params),
    detail: (id: number) => http.get(`/prompts/${id}`),
    create: (data: any) => http.post('/prompts', data),
    toggleFavorite: (id: number) => http.post(`/prompts/${id}/favorite`),
    favorites: () => http.get('/prompts/favorites'),
  },

  community: {
    posts: (params?: any) => http.get('/community/posts', params),
    postDetail: (id: number) => http.get(`/community/posts/${id}`),
    createPost: (data: any) => http.post('/community/posts', data),
    addComment: (postId: number, content: string) =>
      http.post(`/community/posts/${postId}/comments`, { content }),
    toggleLike: (postId: number) => http.post(`/community/posts/${postId}/like`),
    checkLike: (postId: number) => http.get(`/community/posts/${postId}/like`),
  },

  circles: {
    list: (params?: any) => http.get('/circles', params),
    detail: (id: number) => http.get(`/circles/${id}`),
    posts: (id: number, params?: any) => http.get(`/circles/${id}/posts`, params),
    join: (id: number) => http.post(`/circles/${id}/join`),
    leave: (id: number) => http.post(`/circles/${id}/leave`),
    create: (data: any) => http.post('/circles', data),
  },

  sandbox: {
    chat: (data: { model: string; message: string; sessionId?: number }) =>
      http.post('/sandbox/chat', data),
    history: (params?: any) => http.get('/sandbox/history', params),
    quota: () => http.get('/sandbox/quota'),
  },

  search: {
    query: (params: { q: string; type?: string; page?: number; pageSize?: number }) =>
      http.get('/search', params),
  },

  orders: {
    create: (data: { planType: string; amount: number }) => http.post('/orders/create', data),
    list: () => http.get('/orders'),
    detail: (orderNo: string) => http.get(`/orders/${orderNo}`),
  },

  subscriptions: {
    current: () => http.get('/subscriptions/current'),
    list: () => http.get('/subscriptions'),
  },

  dashboard: {
    stats: () => http.get('/dashboard/stats'),
    progress: () => http.get('/dashboard/progress'),
    favorites: () => http.get('/dashboard/favorites'),
  },

  categories: {
    list: () => http.get('/categories'),
  },

  models: {
    list: (params?: any) => http.get('/models', params),
  },

  tools: {
    list: (params?: any) => http.get('/tools', params),
  },

  contents: {
    list: (params?: any) => http.get('/contents', params),
  },
}

import { http } from '../utils/request'
