import http from './http'

// 관리자 태그 관리 API (/api/admin)
export const adminApi = {
  categories() {
    return http.get('/admin/tag-categories')
  },
  createCategory(payload) {
    return http.post('/admin/tag-categories', payload)
  },
  updateCategory(id, payload) {
    return http.put(`/admin/tag-categories/${id}`, payload)
  },
  removeCategory(id) {
    return http.delete(`/admin/tag-categories/${id}`)
  },
  createTag(payload) {
    return http.post('/admin/tags', payload)
  },
  updateTag(id, payload) {
    return http.put(`/admin/tags/${id}`, payload)
  },
  removeTag(id) {
    return http.delete(`/admin/tags/${id}`)
  },

  // 기본(디폴트) 분류 관리 (관리자) — 사용자가 '기본 분류 불러오기'로 가져감
  defaultCategories() {
    return http.get('/admin/default-categories')
  },
  createDefaultCategory(payload) {
    return http.post('/admin/default-categories', payload)
  },
  updateDefaultCategory(id, payload) {
    return http.put(`/admin/default-categories/${id}`, payload)
  },
  removeDefaultCategory(id) {
    return http.delete(`/admin/default-categories/${id}`)
  },
  reorderDefaultCategories(type, ids) {
    return http.put('/admin/default-categories/reorder', { type, ids })
  },

  // 앱 설정 (관리자)
  getSignupSetting() {
    return http.get('/admin/signup-setting')
  },
  setSignupSetting(enabled) {
    return http.put('/admin/signup-setting', { enabled })
  },

  // 회원 관리 (관리자)
  members() {
    return http.get('/admin/members')
  },
  updateMemberRole(id, role) {
    return http.put(`/admin/members/${id}/role`, { role })
  },
  updateMemberPlan(id, plan) {
    return http.put(`/admin/members/${id}/plan`, { plan })
  },
  updateMemberStatus(id, status) {
    return http.put(`/admin/members/${id}/status`, { status })
  },
  removeMember(id) {
    return http.delete(`/admin/members/${id}`)
  },
}
