<?php declare(strict_types=1);

namespace App\Engine\Inertia\Frontend;

abstract class BaseInertiaFrontendController extends \App\Engine\Inertia\BaseInertiaController
{

    public function __construct(
        \Rompetomp\InertiaBundle\Architecture\InertiaInterface                                  $inertia,
        \Symfony\Component\HttpFoundation\RequestStack                                          $requestStack,
        protected readonly SystemConfigurationProvider                                          $systemConfigurationProvider,
        protected readonly \App\Engine\Inertia\Frontend\GeneralContacts\GeneralContactsProvider $generalContactsProvider,
    ) {
        parent::__construct($inertia, $requestStack);
    }

    public function getVueComponent(): string
    {
        return "Frontend/{$this->getId()}";
    }

    protected function getInertiaProps(?\App\Engine\Inertia\InertiaProps $props = null): array
    {
        $props = $props ?? new \App\Engine\Inertia\Frontend\Props\FrontendProps();
        if ($props instanceof \App\Engine\Inertia\Frontend\Props\FrontendProps) {
            $props->generalContacts = $this->generalContactsProvider->provideCached();
        }
        $props->configuration = $this->systemConfigurationProvider->getConfiguration();

        return parent::getInertiaProps($props);
    }

}
