import $ from 'jquery';

export const createLabelsChangeHandler = () => {
	const searchParams = new URLSearchParams(window.location.search);

	if (!searchParams.has('page') || !searchParams.has('tab')) {
		return;
	}

	if ( searchParams.get( 'tab' ) !== 'settings_tab_wetail_shipping' &&
		searchParams.get( 'page' ) !== 'wc-settings') {
		return;
	}

	const tr = $('#mainform tbody tr:not(.wc-settings-row-never-hidden)');

	tr.each(function() {
		if ($(this).hasClass('wc-settings-row-hidden')) {
			$(this).removeClass('wc-settings-row-hidden');
		} else {
			$(this).addClass('wc-settings-row-hidden');
		}
	})
};
