<?php

namespace KupShop\ComponentsBundle\Twig\Components\Utils\Forms\ProductQuestion;

use KupShop\KupShopBundle\Context\UserContext;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class FormType extends AbstractType
{
    public function __construct(private readonly UserContext $userContext)
    {
    }

    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('name', TextType::class, [
                'label' => 'form.label.name',
                'required' => true,
            ])
            ->add('email', EmailType::class, [
                'label' => 'form.label.email',
                'required' => true,
            ])
            ->add('subject', TextType::class, [
                'label' => 'form.label.subject',
            ])
            ->add('comment', TextareaType::class, [
                'label' => 'form.label.comment',
                'required' => true,
            ])
            ->add('pageUrl', HiddenType::class, [
                'label' => 'form.label.page_url',
            ]);
    }

    public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults([
            'data_class' => Entity::class,
            'translation_domain' => 'forms',
        ]);
    }
}
