import $ from 'jquery';
import { close_modal } from '../close_modal';

export const configure_tb_window = ( order_id: string ): void => {
	const TBWindow = $( '.update-product-dimensions' ).parents( '#TB_window' );
	TBWindow.attr( 'data-order_id', order_id );
	TBWindow.wrap( '<div class="tb-window-update-product-dimensions"></div>' );

	// Close button handler
	// @ts-ignore
	$( '#TB_closeWindowButton' ).off( 'click', tb_remove ).on( 'click', close_modal );

	// Remove temporary wrapper on unload
	$( '#TB_window' ).on( 'tb_unload', () => {
		$( '.tb-window-update-product-dimensions' ).remove();
	} );
};
