modificando el patron del sistema, orientado mas al usuario

This commit is contained in:
Lucas Tettamanti
2026-01-25 22:32:58 -03:00
parent 93e331535f
commit bd63d92c50
15 changed files with 707 additions and 83 deletions

View File

@@ -1,4 +1,5 @@
import { api } from "../lib/api.js";
import { modal } from "../lib/modal.js";
class AliasesCrud extends HTMLElement {
constructor() {
@@ -380,7 +381,7 @@ class AliasesCrud extends HTMLElement {
addBtn.onclick = () => {
if (!selectedProductId) {
alert("Selecciona un producto primero");
modal.warn("Selecciona un producto primero");
return;
}
@@ -407,12 +408,12 @@ class AliasesCrud extends HTMLElement {
const categoryInput = this.shadowRoot.getElementById("categoryInput").value.trim();
if (!aliasInput) {
alert("El alias es requerido");
modal.warn("El alias es requerido");
return;
}
if (!this.productMappings.length) {
alert("Agrega al menos un producto");
modal.warn("Agrega al menos un producto");
return;
}
@@ -441,13 +442,14 @@ class AliasesCrud extends HTMLElement {
this.renderForm();
} catch (e) {
console.error("Error saving alias:", e);
alert("Error guardando: " + (e.message || e));
modal.error("Error guardando: " + (e.message || e));
}
}
async delete() {
if (!this.selected?.alias) return;
if (!confirm(`¿Eliminar el alias "${this.selected.alias}"?`)) return;
const confirmed = await modal.confirm(`¿Eliminar el alias "${this.selected.alias}"?`);
if (!confirmed) return;
try {
await api.deleteAlias(this.selected.alias);
@@ -458,7 +460,7 @@ class AliasesCrud extends HTMLElement {
this.renderForm();
} catch (e) {
console.error("Error deleting alias:", e);
alert("Error eliminando: " + (e.message || e));
modal.error("Error eliminando: " + (e.message || e));
}
}