<?php

namespace Planaday\Config\OptionGroups\Booking;

use Planaday\Config\OptionGroups\Booking\Form\BookingFormOptions;
use Planaday\Config\OptionGroups\Booking\Submission\BookingSubmissionOptions;
use Planaday\Config\OptionGroups\OptionGroup;
use Planaday\Platform\PlatformAbstraction\DataHandler;

class BookingOptions extends OptionGroup {
	public const INDEX = '-booking-options';
	private const NAME = 'Booking Options';

	/** @var BookingFormOptions */
	private $formOptions;

	/** @var BookingSubmissionOptions */
	private $submissionOptions;

	public function __construct( DataHandler $dataHandler ) {
		$data     = $dataHandler->getOption( self::INDEX );

		$this->formOptions = new BookingFormOptions( BookingOptionsEnum::BOOKING_FORM, $data[ BookingOptionsEnum::BOOKING_FORM ] ?? []);
		$this->submissionOptions = new BookingSubmissionOptions( BookingOptionsEnum::SUBMISSION, $data[ BookingOptionsEnum::SUBMISSION ] ?? []);

		$layout = [
			$this->formOptions,
			$this->submissionOptions
		];

		parent::__construct( self::INDEX, self::NAME, '', $layout );
	}
	
	public function formOptions(): BookingFormOptions {
		return $this->formOptions;
	}

	public function submissionOptions(): BookingSubmissionOptions {
		return $this->submissionOptions;
	}
}