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

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

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

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

})(jQuery);
