function integrazo_wz_setup_extend_toggleIntegrationStatus(integrationId, checkbox) {
    // If checked, status = 2 (Active); else, status = 3 (Inactive)
    const integration_status = checkbox.checked ? 2 : 3;

    jQuery.ajax({
        url: integrazo_wz_field_mapping.ajax_url,
        type: 'POST',
        data: {
            action: 'integrazo_wz_integration_status',
            integration_id: integrationId,
            integration_status: integration_status,
            security: integrazo_wz_field_mapping.field_mapping_nonce
        },
        success: function(response) {
            if (response.success) {
            } else {
                alert(response.data.message || 'Update failed');
                // Optionally revert toggle on failure
                checkbox.checked = !checkbox.checked;
            }
        },
        error: function() {
            alert('AJAX error occurred.');
            // Optionally revert toggle on error
            checkbox.checked = !checkbox.checked;
        }
    });
}


