<?php

namespace KupShop\ComponentsBundle\Twig\Components\Search\Results;

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

#[AsTwigComponent(template: '@Components/components/Search/Results/TileItems/TileItems.1.html.twig')]
#[Component(1, [
    new Version(1, newJs: null),
])]
class TileItems extends BaseComponent
{
    public array $items;
    public string $type;

    public function getUrl(int $id, string $type): string
    {
        return path('kupshop_content_redirect_redirect', ['type' => $this->type, 'id' => $id]);
    }

    public function getPhotoType()
    {
        return $this->type == 'category' ? 'subsections' : $this->type;
    }

    public function getThumbnail(int $id): ?Thumbnail
    {
        return new Thumbnail((string) $id, $this->type, '');
    }
}
