modificando el patron del sistema, orientado mas al usuario
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { api } from "../lib/api.js";
|
||||
import { modal } from "../lib/modal.js";
|
||||
|
||||
// Datos aleatorios para generar usuarios de prueba
|
||||
const NOMBRES = ["Juan", "María", "Carlos", "Ana", "Pedro", "Laura", "Diego", "Sofía"];
|
||||
@@ -300,7 +301,7 @@ class TestPanel extends HTMLElement {
|
||||
}
|
||||
|
||||
if (this.products.length === 0) {
|
||||
alert("No hay productos con stock disponible");
|
||||
modal.warn("No hay productos con stock disponible");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -420,11 +421,11 @@ class TestPanel extends HTMLElement {
|
||||
this.shadowRoot.getElementById("orderResult").style.display = "block";
|
||||
this.shadowRoot.getElementById("inputAmount").value = result.total || "";
|
||||
} else {
|
||||
alert("Error: " + (result.error || "Error desconocido"));
|
||||
modal.error("Error: " + (result.error || "Error desconocido"));
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("[test-panel] createOrder error:", e);
|
||||
alert("Error creando orden: " + e.message);
|
||||
modal.error("Error creando orden: " + e.message);
|
||||
} finally {
|
||||
this.loading = false;
|
||||
btn.textContent = "Crear Orden en WooCommerce";
|
||||
@@ -435,13 +436,13 @@ class TestPanel extends HTMLElement {
|
||||
async createPaymentLink() {
|
||||
if (this.loading) return;
|
||||
if (!this.lastOrder?.woo_order_id) {
|
||||
alert("Primero creá una orden");
|
||||
modal.warn("Primero creá una orden");
|
||||
return;
|
||||
}
|
||||
|
||||
const amount = parseFloat(this.shadowRoot.getElementById("inputAmount").value);
|
||||
if (!amount || amount <= 0) {
|
||||
alert("Ingresá un monto válido");
|
||||
modal.warn("Ingresá un monto válido");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -464,11 +465,11 @@ class TestPanel extends HTMLElement {
|
||||
this.shadowRoot.getElementById("preferenceIdValue").textContent = result.preference_id || "—";
|
||||
this.shadowRoot.getElementById("paymentResult").style.display = "block";
|
||||
} else {
|
||||
alert("Error: " + (result.error || "Error desconocido"));
|
||||
modal.error("Error: " + (result.error || "Error desconocido"));
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("[test-panel] createPaymentLink error:", e);
|
||||
alert("Error generando link: " + e.message);
|
||||
modal.error("Error generando link: " + e.message);
|
||||
} finally {
|
||||
this.loading = false;
|
||||
btn.textContent = "Generar Link de Pago";
|
||||
@@ -479,7 +480,7 @@ class TestPanel extends HTMLElement {
|
||||
async simulateWebhook() {
|
||||
if (this.loading) return;
|
||||
if (!this.lastOrder?.woo_order_id) {
|
||||
alert("Primero creá una orden");
|
||||
modal.warn("Primero creá una orden");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -501,11 +502,11 @@ class TestPanel extends HTMLElement {
|
||||
this.shadowRoot.getElementById("webhookOrderStatusValue").textContent = result.order_status || "processing";
|
||||
this.shadowRoot.getElementById("webhookResult").style.display = "block";
|
||||
} else {
|
||||
alert("Error: " + (result.error || "Error desconocido"));
|
||||
modal.error("Error: " + (result.error || "Error desconocido"));
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("[test-panel] simulateWebhook error:", e);
|
||||
alert("Error simulando webhook: " + e.message);
|
||||
modal.error("Error simulando webhook: " + e.message);
|
||||
} finally {
|
||||
this.loading = false;
|
||||
btn.textContent = "Simular Pago Exitoso";
|
||||
|
||||
Reference in New Issue
Block a user