import { get_required_element_ids } from './required_element_ids';
import { unset_required } from './unset_required';
import { set_required } from './set_required';

export const toggle_required_dimensions = ( event: JQuery.KeyUpEvent | JQuery.ChangeEvent ) => {
	const total_weight_input_element = event.currentTarget;
	const required_element_ids = get_required_element_ids();

	required_element_ids.forEach( ( id ) => {
		if ( total_weight_input_element.value.length ) {
			unset_required( id );
		} else {
			set_required( id );
		}
	} );

};
