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

    $(document).ready(function () {
        $('.devikit-ifirma-care-banner-remind-later').on('click', function (e) {
            e.preventDefault();
            dismissCareBanner('remind_later');
        });

        $('.devikit-ifirma-care-banner-dismiss-permanent').on('click', function (e) {
            e.preventDefault();
            dismissCareBanner('dismiss_permanent');
        });

        function dismissCareBanner(actionType) {
            $.ajax({
                url: devikitIfirmaCareBanner.ajaxurl,
                type: 'POST',
                data: {
                    action: 'devikit_ifirma_dismiss_care_banner',
                    action_type: actionType,
                    nonce: devikitIfirmaCareBanner.nonce
                },
                success: function (response) {
                    if (response.success) {
                        $('.devikit-ifirma-care-banner').fadeOut(300, function () {
                            $(this).remove();
                        });
                    }
                }
            });
        }
    });

})(jQuery);
