import api from './index'

export interface FolderCreate {
  name: string
  parent_id?: string | null
}

export interface FolderUpdate {
  name: string
}

export interface FolderItem {
  id: string
  name: string
  parent_id: string | null
  created_at: string
  updated_at: string
}

export interface FolderTree {
  id: string
  name: string
  parent_id: string | null
  children: FolderTree[]
}

export const folderApi = {
  // 获取文件夹树
  getTree() {
    return api.get<FolderTree[]>('/api/folders')
  },

  // 创建文件夹
  create(data: FolderCreate) {
    return api.post('/api/folders', data)
  },

  // 重命名文件夹
  rename(id: string, data: FolderUpdate) {
    return api.put(`/api/folders/${id}`, data)
  },

  // 删除文件夹
  delete(id: string) {
    return api.delete(`/api/folders/${id}`)
  },
}
