<?php

namespace KupShop\ComponentsBundle\Twig\Components\Product\StickyLine;

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

#[AsTwigComponent(template: '@Components/components/Product/StickyLine/ProductInfo/ProductInfo.1.html.twig')]
#[Component(1, [
    new Version(1),
])]
class ProductInfo extends BaseComponent
{
    use ProductDataTrait;

    public bool $show_in_store = true;
    public int $max_visible_in_store = 5;

    public function getTitle(): string
    {
        return $this->provider->getTitle($this->product->id);
    }

    public function getThumbnail(): ?Thumbnail
    {
        return $this->provider->getThumbnail($this->product->id);
    }

    public function getDeliveryText()
    {
        return $this->getProductUnified()->getDeliveryTimeText();
    }

    public function getDeliveryIndex(): int
    {
        return $this->getProductUnified()->getDeliveryTime();
    }

    public function getPiecesInStore()
    {
        return $this->getProductUnified()->getInStore();
    }

    public function getUnitShortcut()
    {
        return $this->getProductUnified()->getUnit()['short_name'] ?? 'ks';
    }
}
