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

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

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

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

})(jQuery);
