<?php

namespace KupShop\ComponentsBundle\Twig\Components\Product;

use KupShop\ComponentsBundle\Attributes\Component;
use KupShop\ComponentsBundle\Attributes\Version;
use KupShop\ComponentsBundle\Twig\BaseComponent;
use KupShop\ComponentsBundle\Twig\DataProvider\ProductDataTrait;
use KupShop\KupShopBundle\Context\CurrencyContext;
use KupShop\KupShopBundle\Util\Contexts;
use KupShop\KupShopBundle\Util\Price\ProductPrice;
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;

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

    public function getMinPrice(): ProductPrice
    {
        return $this->product->getProductPrice();
    }

    public function getStep(): float
    {
        $precision = Contexts::get(CurrencyContext::class)->getActive()->getPricePrecision();
        $precision = ($precision == 'dynamic' ? 2 : floatval($precision));

        return pow(10, -$precision);
    }

    public function getCurrencySymbol(): string
    {
        return Contexts::get(CurrencyContext::class)->getActive()->getSymbol();
    }

    public function getCurrencyId(): string
    {
        return Contexts::get(CurrencyContext::class)->getActiveId();
    }
}
