| 1 | import { consume } from "./consume.js" |
| 2 | import { submitFormRecibeJson } from "./submitFormRecibeJson.js" |
| 3 | |
| 4 | /** |
| 5 | * @param {HTMLElement} botonEliminar |
| 6 | * @param {string} mensaje |
| 7 | * @param {string} url |
| 8 | * @param {HTMLFormElement} formulario |
| 9 | * @param {string} nuevaVista |
| 10 | */ |
| 11 | export async function configuraAccionElimina( |
| 12 | botonEliminar, mensaje, url, formulario, nuevaVista |
| 13 | ) { |
| 14 | botonEliminar.addEventListener( |
| 15 | "click", |
| 16 | async () => { |
| 17 | if (confirm(mensaje)) { |
| 18 | await consume(submitFormRecibeJson(url, formulario)) |
| 19 | location.href = nuevaVista |
| 20 | } |
| 21 | } |
| 22 | ) |
| 23 | } |