// Promotional notice dismissal
jQuery(document).ready(function($) {
    $(document).on('click', '.cpbw-promotional-notice-wrapper .notice-dismiss', function(e) {
        e.preventDefault();

        const $notice = $(this).closest('.cpbw-promotional-notice');        

        $.post(ajaxurl, {
            action: 'cpbw_dismiss_promotional_notice',
            nonce: CPBW_NOTICE.nonce
        }, function(response) {
            if (response.success) {
                $notice.fadeOut();
            } else {
                console.error('Dismiss failed:', response.data.message);
            }
        });
    });
});

jQuery(document).ready(function ($) {

    $(document).on(
        'click',
        '.cpbw-review-notice .cpbw-dismiss-review, .cpbw-review-notice .notice-dismiss',
        function (e) {        

            e.preventDefault();

            const $notice = $(this).closest('.cpbw-review-notice');
            const dismissType = $(this).data('dismiss') || 'never';           

            $.post(ajaxurl, {
                action: 'cpbw_dismiss_review_notice',
                dismiss_type: dismissType,
                nonce: CPBW_NOTICE.nonce
            }, function (response) {

                if (response.success) {
                    $notice.fadeOut(200);
                } else {
                    console.error('Dismiss failed:', response?.data?.message || response);
                }

            });
        }
    );

});

