import $ from 'jquery';

export const display_pickup_details = ( has_multiple_senders: boolean, selected_sender_id: string | undefined, form: JQuery<HTMLElement>, should_show_the_popup: boolean, form_heading: string ): {
	should_show_the_popup: boolean
	form_heading: string
} => {
	console.info( 'Pickup time needs to be selected' );

	if ( has_multiple_senders && !selected_sender_id ) {
		form_heading += ' ' + window._wetail_shipping.i18n[ 'and/or' ];
	} else {
		form_heading += ' ' + window._wetail_shipping.i18n[ 'Please' ]
	}

	form_heading += ' ' + window._wetail_shipping.i18n[ 'schedule pickup' ];

	$( `<p class="schedule-pickup"><input id="schedule-pickup" type="checkbox" checked="checked"/><label for="schedule-pickup">${ window._wetail_shipping.i18n[ 'Schedule pickup' ] }</label></p>` ).appendTo( form );
	const datepicker_element = $( `<input required class="sender-and-pickup-form__datepicker" type="text" placeholder="${ window._wetail_shipping.i18n[ 'Choose date' ] }">` );
	datepicker_element.appendTo( form );
	datepicker_element.datetimepicker(
		{
			minDate: 0,
			dateFormat: 'yy-mm-dd',
			timeFormat: 'HH:mm',
			hourMin: 9,
			hourMax: 18,
			hour: 12,
			minuteMax: 0,
			minute: 0,
			showMinute: false,
		},
	);

	$( `<div>${ window._wetail_shipping.i18n[ 'Time is approximate, please contact carrier for information' ] }</div>` ).appendTo( form );

	should_show_the_popup = window.print_label_pickup_time_need;

	return { should_show_the_popup, form_heading };
};
