/**
 * Admin banner functionality
 */
(function ($) {
    'use strict';

    $(document).ready(function () {
        // Handle "Remind me later" button
        $('.devikit-wfirma-banner-remind-later').on('click', function (e) {
            e.preventDefault();
            dismissBanner('remind_later');
        });

        // Handle "Don't remind me anymore" button
        $('.devikit-wfirma-banner-dismiss-permanent').on('click', function (e) {
            e.preventDefault();
            dismissBanner('dismiss_permanent');
        });

        /**
         * Dismiss banner via AJAX
         * @param {string} actionType - Type of action (remind_later or dismiss_permanent)
         */
        function dismissBanner(actionType) {
            $.ajax({
                url: devikitWfirmaBanner.ajaxurl,
                type: 'POST',
                data: {
                    action: 'devikit_wfirma_dismiss_banner',
                    action_type: actionType,
                    nonce: devikitWfirmaBanner.nonce
                },
                success: function (response) {
                    if (response.success) {
                        // Hide the banner with fade effect
                        $('.devikit-wfirma-pro-banner').fadeOut(300, function () {
                            $(this).remove();
                        });
                    } else {
                        console.error('Error dismissing banner:', response.data);
                    }
                },
                error: function (xhr, status, error) {
                    console.error('AJAX error:', error);
                }
            });
        }
    });

})(jQuery);



