<?php

namespace App\Form;

use App\Entity\OnBoaringEpage;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Contracts\Translation\TranslatorInterface;

class EPageOnboard extends AbstractType
{
    public function __construct(private readonly TranslatorInterface $translator)
    {
    }

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name',TextType::class,[
                'label' => 'epage_onboard.name',
                'required' => true,
            ])
            ->add('surname',TextType::class,[
                'label' => 'epage_onboard.surname',
                'required' => true,
            ])
            ->add('email',EmailType::class,[
                'label' => 'epage_onboard.email',
                'required' => true,
            ])
            ->add('birdth',DateType::class,[
                'label' =>'epage_onboard.birdth',
                'required' => true,
                'widget' =>'single_text',
                'mapped' => false,
            ])
            ->add('description',TextareaType::class,[
                'label' => 'epage_onboard.description',
                'required' => true,
                'attr' => [
                    'rows' => 5,
                ]
            ])

            ->add('nameCosplayer',TextType::class,[
                'label' => 'epage_onboard.nameCosplayer',
                'required' => true,
            ])
            ->add('linkInstagram',UrlType::class,[
                'label' => 'epage_onboard.linkInstagram',
                'required' => false,
            ])
            ->add('linkFacebook',UrlType::class,[
                'label' => 'epage_onboard.linkFacebook',
                'required' => false,
            ])
            ->add('linkTiktok',UrlType::class,[
                'label' => 'epage_onboard.linkTiktok',
                'required' => false,
            ])
            ->add('linkX',UrlType::class,[
                'label' => 'epage_onboard.linkX',
                'required' => false,
            ])
            ->add('useDomain',CheckboxType::class,[
                'label' => 'epage_onboard.useDomain',
                'required' => false,
            ])
            ->add('epage',FileType::class,[
                'required' => true,
                'label' => 'epage_onboard.avatar',
                'attr' =>[
                    'label' => $this->translator->trans('epage_onboard.avatar_label'),
                    'multiple' => false,
                    'accept' => 'image/*',
                    'is' => 'drop-files'
                ]
            ])
            ->add('domain',TextType::class,[
                'label' => 'epage_onboard.domain',
                'required' => true,
            ])
            ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefault('data_class',OnBoaringEpage::class);
    }
}
