jQuery(document).ready(function () {
    function integrazo_fwcrm_form_SendReviewAction(actionType, nonce) {
        jQuery.post(ajaxurl, { 
            action: 'integrazo_fwcrm_form_review_action', 
            action_type: actionType,
            nonce: nonce
        }, function(response) {
            if (response.success) {
                jQuery('#iafwhc-review-notice').fadeOut();
            } else {
                alert('Error: ' + response.data.message);
            }
        }).fail(function() {
            alert('Request failed. Please try again.');
        });
    }

    // Handle "Remind Me Later" click
    jQuery('#iafwhc-review-later').on('click', function(e) {
        e.preventDefault();
        let nonce = jQuery(this).data('nonce');
        integrazo_fwcrm_form_SendReviewAction('later', nonce);
    });

    // Handle "Already Provided" click
    jQuery('#iafwhc-review-dismiss').on('click', function(e) {
        e.preventDefault();
        let nonce = jQuery(this).data('nonce');
        integrazo_fwcrm_form_SendReviewAction('dismiss', nonce);
    });
});
