<?php

class OrderAction extends FrontControl 
{
  
  	public function __construct(, 
		Order $order, 
		Model\OrderAction $orderAction,
		Container $container
	) 
	{
		parent::__construct();

		$this->order = $order;
		$this->orderAction = $orderAction;
		$this->actions = $this->orderAction->getActions($this->pageByState);
	}
	
	
	
	public function render(array $config = [])
	{
		$config = $this->getCurrentConfig($config);

		$this->template->order = $this->order;
		$this->template->actions = $this->actions;

		$this->vueRender($config);
	}

	public function createComponent(string $name): ?Nette\ComponentModel\IComponent
	{
		if (!Strings::startsWith($name, 'action')) {
			return parent::createComponent($name);
		}

		return $this->container->createInstance('App\\FrontModule\\Components\\' . $this->actions[Strings::after($name, 'action')]->action, [
			'orderAction' => $this->actions[Strings::after($name, 'action')],
			'order' => $this->order
		]);
	}
	

}