jQuery( document ).ready( function() {

	jQuery( '.elex_mv_general_settings_vendor' ).click( function() {
		var link = elex_mv_admin_ajaxurl_object.ajax_url;
		link += '?action=elex_mv_vendor_general_settings_details';
		var formData = new FormData( document.getElementById( 'elex_mv_vendor_general_settings' ) );

		jQuery.ajax( {
			url: link,
			type: 'POST',
			data: formData,
			enctype: 'multipart/form-data',
			processData: false,
			contentType: false,
			success: function( result ) {
				if ( result.success ) {
					if ( result.data.verify_user_review ) {
						jQuery( '.verify_user' ).attr( 'checked', true );
					} else {
						jQuery( '.verify_user' ).attr( 'checked', false );
					}
					if ( result.data.coupon_notification ) {
						jQuery( '.notify_coupon' ).attr( 'checked', true );
					} else {
						jQuery( '.notify_coupon' ).attr( 'checked', false );
					}
					if ( result.data.flat_service_enable ) {
						jQuery( '.flat_rate_service' ).attr( 'checked', true );
					} else {
						jQuery( '.flat_rate_service' ).attr( 'checked', false );
					}

					var saved = document.getElementById( 'vendor_select_setting_saved_success_toast' );
					var toast = new bootstrap.Toast( saved );
					toast.show();
					setTimeout( function() {
						window.location.reload();
					}, 1000 );
				}
			},
		} );
	} );

} );
