<?php
/**
 * @var array $fields
 * @var bool $disabled
 * @var string $dimension_unit
 * @var int $package_number
 *
 * @package DhlPolska\Shipment\Metabox\Field
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

?>

<div class="dhl-polska-package-row js--package-row">
	<strong class="dhl-polska-package-name"><?php esc_html_e( 'Paczka #', 'dhl-polska' ); ?></strong>

	<?php
	foreach ( $fields as $key => $field_args ) {
		$fields[ $key ]['id'] = sanitize_title( $field_args['key'] );
		if ( $disabled ) {
			$fields[ $key ]['custom_attributes'] = array_merge(
				$field_args['custom_attributes'] ?? [],
				[ 'disabled' => 'disabled' ]
			);
		}
	}

	woocommerce_form_field( $fields['type']['key'], $fields['type'], $fields['type']['value'] );
	woocommerce_form_field( $fields['weight']['key'], $fields['weight'], $fields['weight']['value'] );
	?>

	<div class="form-row dhl-polska-dimensions-row">
		<label>
			<?php
			printf(
				// Translators: dimension unit.
				esc_html__( 'Wymiary (dł / sz / wys) [%s]', 'dhl-polska' ),
				esc_html( $dimension_unit )
			);
			?>
		</label>
		<div class="dhl-polska-dimensions-fields">
			<?php
			woocommerce_form_field( $fields['length']['key'], $fields['length'], $fields['length']['value'] );
			echo '<span class="separator">/</span>';
			woocommerce_form_field( $fields['width']['key'], $fields['width'], $fields['width']['value'] );
			echo '<span class="separator">/</span>';
			woocommerce_form_field( $fields['height']['key'], $fields['height'], $fields['height']['value'] );
			?>
		</div>
	</div>

	<?php if ( ! $disabled ) : ?>
		<div class="dhl-polska-package-buttons">
			<a href="#0"
				data-integration="dhl_polska"
				class="button-delete js--delete-package"><?php esc_html_e( 'Usuń paczkę', 'dhl-polska' ); ?></a>
		</div>
	<?php endif; ?>
</div>
