<?php
/**
 * Default options for checkout blocks pickup point selection.
 *
 * @package DhlPolska\CheckoutBlocks
 */

namespace DhlPolska\CheckoutBlocks;

use DhlPolska\Point\CheckoutChoosePointField;
use DhlPolskaVendor\WPDesk\PluginBuilder\Plugin\Hookable;

class DefaultOptions implements Hookable {

	/**
	 * @var string
	 */
	private string $integration_name;

	/**
	 * @param string $integration_name .
	 */
	public function __construct( string $integration_name ) {
		$this->integration_name = $integration_name;
	}

	/**
	 * @return void
	 */
	public function hooks(): void {
		add_filter( 'octolize-pickup-point-blocks-' . $this->integration_name . '-data', [ $this, 'set_integration_data' ] );
	}

	/**
	 * @param array<mixed> $data .
	 *
	 * @return array<string, mixed>
	 */
	public function set_integration_data( $data ): array {
		if ( ! is_array( $data ) ) { /* @phpstan-ignore-line */
			$data = [];
		}

		$data['disable_list_selection'] = true;
		$data['disable_map_selection']  = false;
		$data['field_label']            = __( 'Punkt odbioru DHL:', 'dhl-polska' );
		$data['button_label']           = __( 'Wybierz punkt z mapy', 'dhl-polska' );

		$data[ CheckoutChoosePointField::FIELD_PARCELSHOP_ID ] = '';
		$data['default_options']                               = [
			[
				'label' => __( 'Wybierz punkt z mapy', 'dhl-polska' ),
			],
		];

		return $data;
	}
}
