<?php

declare(strict_types=1);

namespace KupShop\PreordersBundle\Twig\Components\Preorders;

use KupShop\ComponentsBundle\Attributes\Component;
use KupShop\ComponentsBundle\Attributes\Version;
use KupShop\ComponentsBundle\Twig\BaseComponent;
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;

#[AsTwigComponent(template: '@Preorders/components/Filter/Filter.1.html.twig')]
#[Component(1, [
    new Version(1, newCss: null),
])]
class Filter extends BaseComponent
{
    public array $shownFilters = ['sections', 'producers'];

    public int $dateId;
    public \Filter $filter;
    public int $sectionsLevel = 1;

    public function getBaseFilterParams(): \FilterParams
    {
        $filterParams = new \FilterParams();
        $filterParams->setSections([0]);

        return $filterParams;
    }

    public function getDynamicFilter(): object
    {
        $this->filter->setValuesCache(array_merge(
            $this->filter->getValuesCache(),
            ['sections' => $this->filter->getLeafSections()],
        ));

        $this->filter->getPriceRange();
        $this->filter->getProducers();

        $this->filter->getInStore();
        $this->filter->getInStore(\Filter::IN_STORE_SUPPLIER);

        return (object) $this->filter->getValuesCache();
    }

    public function getFilterParams(): object
    {
        return (object) $this->filter->getFilterParams()->getParams();
    }
}
