jQuery(document).ready(function($) {
    $('.delete-license').on('click', function(e) {
        e.preventDefault();
        if (!confirm('Are you sure you want to delete this license?')) {
            return;
        }
        
        var $this = $(this);
        var licenseId = $this.data('id');
        
        $.ajax({
            url: ajaxurl,
            type: 'POST',
            data: {
                action: 'chainpay_delete_license',
                nonce: chainpay_admin.nonce,
                license_id: licenseId
            },
            success: function(response) {
                if (response.success) {
                    $this.closest('tr').fadeOut();
                } else {
                    alert('Error: ' + response.data);
                }
            },
            error: function() {
                alert('An error occurred');
            }
        });
    });
});
