<?php

declare(strict_types=1);

namespace App\Form;

use App\Entity\Section;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
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;

final class SectionType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('nom', TextType::class, ['label' => 'Nom de la section'])
            ->add('slug', TextType::class, ['label' => 'Slug', 'attr' => ['placeholder' => 'section-femmes-en-ligne']])
            ->add('type', ChoiceType::class, [
                'label' => 'Type',
                'choices' => ['En ligne' => 'EN_LIGNE', 'Présentiel' => 'PRESENTIEL', 'WhatsApp' => 'WHATSAPP', 'Mixte' => 'MIXTE', 'Personnalisé' => 'PERSONNALISE'],
            ])
            ->add('publicCible', TextType::class, ['label' => 'Public cible', 'required' => false])
            ->add('description', TextareaType::class, ['label' => 'Description', 'required' => false, 'attr' => ['rows' => 4]])
            ->add('ordre', IntegerType::class, ['label' => 'Ordre', 'attr' => ['min' => 0]])
            ->add('whatsappGroupId', TextType::class, [
                'label' => 'ID groupe WhatsApp',
                'required' => false,
                'help' => 'Optionnel. Exemple : 120363...@g.us',
            ])
            ->add('whatsappGroupInviteLink', TextType::class, [
                'label' => 'Lien d’invitation WhatsApp',
                'required' => false,
                'help' => 'Utilisé si l’ajout automatique au groupe échoue.',
            ])
            ->add('active', CheckboxType::class, ['label' => 'Section active', 'required' => false]);
    }
    public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults(['data_class' => Section::class]); }
}
