<?php

namespace Planaday\Config\OptionGroups\Booking\Form\Materials;

use Planaday\Config\OptionGroups\Booking\BookingOptions;
use Planaday\Config\OptionGroups\OptionGroup;
use Planaday\Config\OptionTypes\BoolOption;
use Planaday\Config\OptionTypes\StringOption;
use Planaday\Config\OptionTypes\TextOption;
use Planaday\Utility\DependencyInjection\ComponentRegistry;
use Planaday\Utility\DependencyInjection\ComponentRegistryShortCut;

class MaterialsOptions extends OptionGroup implements ComponentRegistryShortCut {
	private const NAME = 'Materiaal';
	private const DESCRIPTION = 'Opties over de materialen die weergeven kunnen worden bij het boeken van een cursus.';
	
	/** @var BoolOption<bool> */
	private $askMaterialsBookingForm;
	
	/** @var BoolOption<bool> */
	private $showDescriptionMaterials;
	
	/** @var BoolOption<bool> */
	private $showBothWithAndWithoutTaxPrice;
	
	/** @var StringOption<string> */
	private $materialsFormTitle;
	
	/** @var TextOption<null> */
	private $materialsFormDescription;

	public function __construct( string $index, array $data ) {
		$this->askMaterialsBookingForm = new BoolOption(
			MaterialsOptionsEnum::ASK_MATERIALS_BOOKING_FORM,
			'Toon materialen in boekingsformulier',
			'Toon materialen indien er materialen in een dagdeel bij een cursus gekoppeld zijn en beschikbaar zijn voor de api. <br>' .
			'Dan kan de bezoeker deze meteen meebestellen.',
			$data[ MaterialsOptionsEnum::ASK_MATERIALS_BOOKING_FORM ] ?? null,
			false
		);
		
		$this->showDescriptionMaterials = new BoolOption(
			MaterialsOptionsEnum::SHOW_DESCRIPTION_MATERIALS,
			'Toon omschrijving',
			'Toon bij de materialen een omschrijving van het materiaal.',
			$data[ MaterialsOptionsEnum::SHOW_DESCRIPTION_MATERIALS ] ?? null,
			false
		);
		
		$this->showBothWithAndWithoutTaxPrice = new BoolOption(
			MaterialsOptionsEnum::SHOW_BOTH_WITH_AND_WITHOUT_TAX_PRICE,
			'Toon prijs met en zonder BTW',
			'Toon bij de materialen de prijs met en zonder BTW. Ander wordt alleen de standaardprijs getoond.',
			$data[ MaterialsOptionsEnum::SHOW_BOTH_WITH_AND_WITHOUT_TAX_PRICE ] ?? null,
			false
		);
		
		$this->materialsFormTitle = new StringOption(
			MaterialsOptionsEnum::MATERIALS_FORM_TITLE,
			'Titel in formulier',
			'Welke titel moet in het formulier getoond worden?',
			$data[ MaterialsOptionsEnum::MATERIALS_FORM_TITLE ] ?? null,
			"Welke opties zou je willen meebestellen?"
		);
		
		$this->materialsFormDescription = new TextOption(
			MaterialsOptionsEnum::MATERIALS_FORM_DESCRIPTION,
			'Omschrijving in formulier',
			'Welke omschrijving over de materialen moet in het formulier getoond worden? <br>' .
			'<b><i>Gebruik hier geen shortcodes of plugins</i></b>',
			$data[ MaterialsOptionsEnum::MATERIALS_FORM_DESCRIPTION ] ?? null,
			null
		);

		$layout = [
			$this->askMaterialsBookingForm,
			$this->showDescriptionMaterials,
			$this->showBothWithAndWithoutTaxPrice,
			$this->materialsFormTitle,
			$this->materialsFormDescription
		];
		parent::__construct( $index, self::NAME, self::DESCRIPTION, $layout );
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function askMaterialsBookingForm(): BoolOption {
		return $this->askMaterialsBookingForm;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showDescriptionMaterials(): BoolOption {
		return $this->showDescriptionMaterials;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showBothWithAndWithoutTaxPrice(): BoolOption {
		return $this->showBothWithAndWithoutTaxPrice;
	}

	/**
	 * @return StringOption<string>
	 */
	public function materialsFormTitle(): StringOption {
		return $this->materialsFormTitle;
	}

	/**
	 * @return TextOption<null>
	 */
	public function materialsFormDescription(): TextOption {
		return $this->materialsFormDescription;
	}

	public static function componentRegistryConstruct( ComponentRegistry $registry ) {
		return $registry->getComponent(BookingOptions::class)->formOptions()->materials();
	}
}