<?php

namespace KupShop\ComponentsBundle\Twig\Components\Account\UserDashboard;

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

#[AsTwigComponent(template: '@Components/components/Account/UserDashboard/UserInfoWithPhoto/UserInfoWithPhoto.1.html.twig')]
#[Component(1, [
    new Version(1, newJs: null),
])]
class UserInfoWithPhoto extends BaseComponent
{
    public array $userInfo;

    public function __construct(private readonly UserContext $userContext)
    {
    }

    public function getNameRaw(): string
    {
        return $this->userContext->getActive()->name ?? '';
    }

    public function getSurnameRaw(): string
    {
        return $this->userContext->getActive()->surname ?? '';
    }

    public function getName(): ?string
    {
        return $this->userInfo['contact']['name'] ?? null;
    }

    public function getStreet(): ?string
    {
        return $this->userInfo['address']['street'] ?? null;
    }

    public function getCity(): ?string
    {
        return $this->userInfo['address']['city'] ?? null;
    }

    public function getEmail(): ?string
    {
        return $this->userInfo['contact']['email'] ?? null;
    }

    public function getPhone(): ?string
    {
        return $this->userInfo['contact']['phone'] ?? null;
    }

    public function isUserB2B(): bool
    {
        return $this->userContext->getActive()->isType('b2b');
    }
}
