jQuery(document).ready(function($){
    'use strict';
    $("#fsx_install_btn, #fsx_activate_btn").click(function(e) {
        e.preventDefault();
        const that = $(this);
        const action = that.attr("id") == 'fsx_install_btn' ? 'ultp_install' : 'ultp_activate';
        
        $.ajax({
            type: 'POST',
            url: ajaxurl,
            data: { action: action },
            beforeSend: function(){
                that.parents('.fsx_wc_imports').addClass('fsx_loading');
            },
            success: function(response) {
                setTimeout(()=> {
                    that.parents('.fsx_wc_imports').removeClass('fsx_loading');
                }, 1500);
                if ( response.success ) {
                    window.location.href = response.data.redirect;
                } else {
                    window.location.reload();
                }
            }
        });
    });
    $(".fsx_admin_notice_close").click(function(e) {
        e.preventDefault();
        $(this).parents('.fsx_admin_notice_wrapper').css('display', 'none');
        $.ajax({
            type: 'POST',
            url: ajaxurl,
            data: { action: 'disbale_postx_notice' },
            success: function(response) {
            }
        });
    });
});