<script>
document.addEventListener('submit', function (e) {

    if (!e.target.classList.contains('delete-form')) return;

    if (e.target.dataset.confirmed) return;

    e.preventDefault();

    Swal.fire({
        title: "Eliminar registro",
        text: "¿Estás seguro?",
        icon: "warning",
        showCancelButton: true,
        confirmButtonText: "Eliminar",
        cancelButtonText: "Regresar",
    }).then((result) => {
        if (result.isConfirmed) {
            e.target.dataset.confirmed = true;
            e.target.submit();
        }
    });

});
</script>

    @if(session('swal'))
        <script>
            Swal.fire(@json(session('swal')))
        </script>
    @endif
