import request from '@/utils/request'

// ── categories ──────────────────────────────────────────────────────────────

export function getPkgCategoryTree() {
  return request.get('/packages/categories')
}

export function createPkgCategory(payload) {
  return request.post('/packages/categories', payload)
}

export function updatePkgCategory(categoryId, payload) {
  return request.put(`/packages/categories/${categoryId}`, payload)
}

export function deletePkgCategory(categoryId) {
  return request.delete(`/packages/categories/${categoryId}`)
}

// ── data files (for selection) ───────────────────────────────────────────────

export function getAllDataFiles() {
  return request.get('/packages/data-files')
}

// ── packages ─────────────────────────────────────────────────────────────────

export function getPackages(params) {
  return request.get('/packages', { params })
}

export function createPackage(payload) {
  return request.post('/packages', payload)
}

export function deletePackage(packageId) {
  return request.delete(`/packages/${packageId}`)
}

export function getPackageRecords(packageId, params) {
  return request.get(`/packages/${packageId}/records`, { params })
}

export function previewPackage(payload, params) {
  return request.post('/packages/preview', payload, { params })
}
