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 ProductsCrud extends HTMLElement {
|
||||
constructor() {
|
||||
@@ -166,13 +167,10 @@ class ProductsCrud extends HTMLElement {
|
||||
|
||||
async syncFromWoo() {
|
||||
// Mostrar confirmación antes de sincronizar
|
||||
const confirmed = confirm(
|
||||
const confirmed = await modal.confirm(
|
||||
"⚠️ Resincronización de emergencia\n\n" +
|
||||
"Esto reimportará TODOS los productos desde WooCommerce y sobrescribirá los datos locales.\n\n" +
|
||||
"Usar solo si:\n" +
|
||||
"• La plataforma estuvo caída mientras se hacían cambios en Woo\n" +
|
||||
"• Los webhooks no funcionaron correctamente\n" +
|
||||
"• Necesitás una sincronización completa\n\n" +
|
||||
"Usar solo si la plataforma estuvo caída, los webhooks no funcionaron, o necesitás una sincronización completa.\n\n" +
|
||||
"¿Continuar?"
|
||||
);
|
||||
|
||||
@@ -185,14 +183,14 @@ class ProductsCrud extends HTMLElement {
|
||||
try {
|
||||
const result = await api.syncFromWoo();
|
||||
if (result.ok) {
|
||||
alert(`Sincronización completada: ${result.synced} productos importados`);
|
||||
modal.success(`Sincronización completada: ${result.synced} productos importados`);
|
||||
} else {
|
||||
alert("Error: " + (result.error || "Error desconocido"));
|
||||
modal.error("Error: " + (result.error || "Error desconocido"));
|
||||
}
|
||||
await this.load();
|
||||
} catch (e) {
|
||||
console.error("Error syncing products:", e);
|
||||
alert("Error sincronizando: " + (e.message || e));
|
||||
modal.error("Error sincronizando: " + (e.message || e));
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
btn.textContent = "Resincronizar";
|
||||
@@ -636,7 +634,7 @@ class ProductsCrud extends HTMLElement {
|
||||
setTimeout(() => { btn.textContent = "Guardar cambios"; btn.disabled = false; }, 1500);
|
||||
} catch (e) {
|
||||
console.error("Error saving product:", e);
|
||||
alert("Error guardando: " + (e.message || e));
|
||||
modal.error("Error guardando: " + (e.message || e));
|
||||
btn.textContent = "Guardar cambios";
|
||||
btn.disabled = false;
|
||||
}
|
||||
@@ -710,7 +708,7 @@ class ProductsCrud extends HTMLElement {
|
||||
const categoryName = select.value;
|
||||
|
||||
if (!categoryName) {
|
||||
alert("Seleccioná una categoría");
|
||||
modal.warn("Seleccioná una categoría");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -753,7 +751,7 @@ class ProductsCrud extends HTMLElement {
|
||||
setTimeout(() => { btn.textContent = "Agregar"; btn.disabled = false; }, 1500);
|
||||
} catch (e) {
|
||||
console.error("Error adding category:", e);
|
||||
alert("Error agregando categoría: " + (e.message || e));
|
||||
modal.error("Error agregando categoría: " + (e.message || e));
|
||||
btn.textContent = "Agregar";
|
||||
btn.disabled = false;
|
||||
}
|
||||
@@ -804,7 +802,7 @@ class ProductsCrud extends HTMLElement {
|
||||
}, 1500);
|
||||
} catch (e) {
|
||||
console.error("Error saving product unit:", e);
|
||||
alert("Error guardando: " + (e.message || e));
|
||||
modal.error("Error guardando: " + (e.message || e));
|
||||
btn.textContent = count > 1 ? `Guardar para ${count}` : "Guardar";
|
||||
btn.disabled = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user