modificando el patron del sistema, orientado mas al usuario
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { api } from "../lib/api.js";
|
||||
import { on } from "../lib/bus.js";
|
||||
import { navigateToItem } from "../lib/router.js";
|
||||
import { modal } from "../lib/modal.js";
|
||||
|
||||
class RecommendationsCrud extends HTMLElement {
|
||||
static get observedAttributes() {
|
||||
@@ -661,7 +662,7 @@ class RecommendationsCrud extends HTMLElement {
|
||||
|
||||
addBtn.onclick = () => {
|
||||
if (!selectedProductId) {
|
||||
alert("Selecciona un producto primero");
|
||||
modal.warn("Selecciona un producto primero");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -792,7 +793,7 @@ class RecommendationsCrud extends HTMLElement {
|
||||
const active = this.shadowRoot.getElementById("activeInput").checked;
|
||||
|
||||
if (!ruleKey) {
|
||||
alert("El nombre de la regla es requerido");
|
||||
modal.warn("El nombre de la regla es requerido");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -812,11 +813,11 @@ class RecommendationsCrud extends HTMLElement {
|
||||
|
||||
if (this.currentRuleType === "crosssell") {
|
||||
if (!this.selectedTriggerProducts.length) {
|
||||
alert("Selecciona al menos un producto trigger");
|
||||
modal.warn("Selecciona al menos un producto trigger");
|
||||
return;
|
||||
}
|
||||
if (!this.selectedRecommendedProducts.length) {
|
||||
alert("Selecciona al menos un producto para recomendar");
|
||||
modal.warn("Selecciona al menos un producto para recomendar");
|
||||
return;
|
||||
}
|
||||
data.trigger_product_ids = this.selectedTriggerProducts;
|
||||
@@ -827,7 +828,7 @@ class RecommendationsCrud extends HTMLElement {
|
||||
data.trigger_event = triggerEvent;
|
||||
|
||||
if (!this.ruleItems.length) {
|
||||
alert("Agrega al menos un producto con cantidad");
|
||||
modal.warn("Agrega al menos un producto con cantidad");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -853,13 +854,14 @@ class RecommendationsCrud extends HTMLElement {
|
||||
this.renderForm();
|
||||
} catch (e) {
|
||||
console.error("Error saving recommendation:", e);
|
||||
alert("Error guardando: " + (e.message || e));
|
||||
modal.error("Error guardando: " + (e.message || e));
|
||||
}
|
||||
}
|
||||
|
||||
async delete() {
|
||||
if (!this.selected?.id) return;
|
||||
if (!confirm(`¿Eliminar la regla "${this.selected.rule_key}"?`)) return;
|
||||
const confirmed = await modal.confirm(`¿Eliminar la regla "${this.selected.rule_key}"?`);
|
||||
if (!confirmed) return;
|
||||
|
||||
try {
|
||||
await api.deleteRecommendation(this.selected.id);
|
||||
@@ -869,7 +871,7 @@ class RecommendationsCrud extends HTMLElement {
|
||||
this.renderForm();
|
||||
} catch (e) {
|
||||
console.error("Error deleting recommendation:", e);
|
||||
alert("Error eliminando: " + (e.message || e));
|
||||
modal.error("Error eliminando: " + (e.message || e));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user