-
-
Save parzibyte/57aec9b7382a441c486fc2647fed98b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const respuestaConfirmacion = await Swal.fire({ | |
title: "Confirmación", | |
text: "¿Eliminar el producto? esto no se puede deshacer", | |
icon: 'warning', | |
showCancelButton: true, | |
cancelButtonColor: '#3085d6', | |
confirmButtonColor: '#d33', | |
confirmButtonText: 'Sí, eliminar', | |
cancelButtonText: 'Cancelar', | |
}); | |
if (respuestaConfirmacion.value) { | |
const url = `./eliminar_producto.php?id=${idProducto}`; | |
const respuestaRaw = await fetch(url, { | |
method: "DELETE", | |
}); | |
const respuesta = await respuestaRaw.json(); | |
if (respuesta) { | |
Swal.fire({ | |
icon: "success", | |
text: "Producto eliminado", | |
timer: 700, // <- Ocultar dentro de 0.7 segundos | |
}); | |
} else { | |
Swal.fire({ | |
icon: "error", | |
text: "El servidor no respondió con una respuesta exitosa", | |
}); | |
} | |
// De cualquier modo, volver a obtener los productos para refrescar la tabla | |
obtenerProductos(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment