'use strict'; document.addEventListener('DOMContentLoaded', function (e) { (function () { const deleteButtons = document.querySelectorAll('.delete-transaction'); deleteButtons.forEach(deleteButton => { deleteButton.addEventListener('click', function (e) { e.preventDefault(); const userName = this.getAttribute('data-transaction-username'); Swal.fire({ title: 'Delete Transaction?', html: `

Are you sure you want to delete transaction of ?
${userName}

`, icon: 'warning', showCancelButton: true, confirmButtonText: 'Delete', cancelButtonText: 'Cancel', customClass: { confirmButton: 'btn btn-danger waves-effect waves-light', cancelButton: 'btn btn-label-secondary waves-effect waves-light' } }).then(result => { if (result.isConfirmed) { window.location.href = this.getAttribute('href'); //redirect to herf } else { Swal.fire({ title: 'Cancelled', html: `

Did not delete ${userName} Transaction!

`, icon: 'error', confirmButtonText: 'Ok', customClass: { confirmButton: 'btn btn-success waves-effect waves-light' } }); } }); }); }); })(); });