import ApiService from "@/services/ApiService";

const catBase = "admin/laundry-sale-categories";
const prodBase = "admin/laundry-sale-products";

export async function listCategories() {
  const response = await ApiService.get(catBase);
  return response.data;
}

export async function createCategory(payload) {
  const response = await ApiService.post(catBase, payload);
  return response.data;
}

export async function updateCategory(id, payload) {
  const response = await ApiService.put(`${catBase}/${id}`, payload);
  return response.data;
}

export async function disableCategory(id) {
  const response = await ApiService.patch(`${catBase}/${id}/disable`);
  return response.data;
}

export async function deleteCategory(id) {
  const response = await ApiService.delete(`${catBase}/${id}`);
  return response.data;
}

/** @param {'producto'|'servicio'|''} [tipo] */
export async function listProducts(tipo) {
  const params = tipo ? { tipo } : undefined;
  const response = await ApiService.get(prodBase, { params });
  return response.data;
}

export async function createProduct(payload) {
  const response = await ApiService.post(prodBase, payload);
  return response.data;
}

export async function updateProduct(id, payload) {
  const response = await ApiService.put(`${prodBase}/${id}`, payload);
  return response.data;
}

export async function disableProduct(id) {
  const response = await ApiService.patch(`${prodBase}/${id}/disable`);
  return response.data;
}

export async function deleteProduct(id) {
  const response = await ApiService.delete(`${prodBase}/${id}`);
  return response.data;
}
