import ApiService from "@/services/ApiService";

const baseUrl = "ventas";

const POS_CATALOG_TIMEOUT_MS = 45000;
const catalogConfig = { timeout: POS_CATALOG_TIMEOUT_MS };

export const getVentasMensuales = async (year = null, month = null) => {
  const params = {};
  if (year) params.year = year;
  if (month) params.month = month;
  const response = await ApiService.get(`${baseUrl}/mensual`, { params });
  return response.data;
};

/**
 * Catálogo POS: prioridades, tipos de prenda, tipos de carga (TIBU).
 */
export const getPosCatalog = async () => {
  const response = await ApiService.get("laundry/pos-catalog", catalogConfig);
  return response.data;
};

/** Vista previa de totales (mismas reglas que crear orden con ítems). */
export const postPosPreviewTotals = async (payload) => {
  const response = await ApiService.post("laundry/pos/preview-totals", payload, catalogConfig);
  return response.data;
};
