jQuery( document ).ready( function() {
	var popoverTriggerList = [].slice.call( document.querySelectorAll( '[data-bs-toggle="popover"]' ) );
	var popoverList = popoverTriggerList.map( function( popoverTriggerEl ) {
		return new bootstrap.Popover( popoverTriggerEl, { container: '.elex-multi-vendor-for-woocommerce-wrap-front' } );
	} );
} );

function changeProductStatusFunc( id ) {
	var form;

	var toggle_status_page_link = elex_mv_admin_ajaxurl_object.ajax_url;
	toggle_status_page_link = toggle_status_page_link + '?action=elex_mv_toggle_page_link';

	if ( jQuery( '#elex_mv_check_enable_' + id ).is( ':checked' ) ) {
		form = {
			id: id,
			visibility: 'yes',
			nonce: elex_mv_coupon_ajaxurl_object.nonce,
		};
	} else {
		form = {
			id: id,
			visibility: 'no',
			nonce: elex_mv_coupon_ajaxurl_object.nonce,
		};
	}

	jQuery.ajax( {
		url: toggle_status_page_link,
		type: 'POST',
		data: form,
		enctype: 'text/plain',
		success: function() {
			var additem = document.getElementById( 'elex_msging_for_bulk_action_vendor' );
			jQuery( '#elex_msging_for_bulk_action_vendor_msg' ).html( 'Status changed successfully' );
			var toast = new bootstrap.Toast( additem );
			toast.show();
			const myTimeout = setTimeout( function myStopFunction() {
				location.reload();
			}, 2000 );
		},
		error: function() {
			var additem = document.getElementById( 'elex_msging_for_bulk_action_vendor' );
			jQuery( '#elex_msging_for_bulk_action_vendor' ).html( 'Status not changed' );
			var toast = new bootstrap.Toast( additem );
			toast.show();
			const myTimeout = setTimeout( function myStopFunction() {
				location.reload();
			}, 2000 );
		},
	} );
}
