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

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

        // Handle "Don't remind me anymore" button
        $('.devikit-fakturowo-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: devikitFakturowoBanner.ajaxurl,
                type: 'POST',
                data: {
                    action: 'devikit_fakturowo_dismiss_banner',
                    action_type: actionType,
                    nonce: devikitFakturowoBanner.nonce
                },
                success: function (response) {
                    if (response.success) {
                        // Hide the banner with fade effect
                        $('.devikit-fakturowo-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);






