This commit is contained in:
2026-02-08 12:44:17 +01:00
parent 2e569a7ffd
commit d0ccfb5626
4 changed files with 170 additions and 1 deletions

View File

@ -318,6 +318,50 @@ export default class PresupuestoWizard {
document.body.removeChild(a);
});
$(document)
.off('click.login-required', '.btn-login-required')
.on('click.login-required', '.btn-login-required', async (e) => {
e.preventDefault();
const rawId = this.opts.presupuestoId || window.PRESUPUESTO_ID || $('#presupuesto_id').val();
const presupuestoId = rawId ? parseInt(rawId, 10) : null;
if (!presupuestoId || Number.isNaN(presupuestoId)) {
Swal.fire({
icon: 'error',
title: 'No se encontró el presupuesto',
text: 'Vuelve a generar el resumen e inténtalo de nuevo.',
buttonsStyling: false,
customClass: {
confirmButton: 'btn btn-secondary me-2',
cancelButton: 'btn btn-light'
},
});
return;
}
try {
await $.ajax({
url: '/presupuesto/public/prepare-claim',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({ presupuestoId })
});
window.location.assign('/presupuesto/claim');
} catch (err) {
Swal.fire({
icon: 'error',
title: 'No se pudo continuar',
text: 'Inténtalo de nuevo en unos segundos.',
buttonsStyling: false,
customClass: {
confirmButton: 'btn btn-secondary me-2',
cancelButton: 'btn btn-light'
},
});
}
});
}