<?php

namespace AutoAdmin\Bundle\Admin\Form;

use AutoAdmin\Bundle\Admin\Form\Type\Component\DatePickerType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class CookieConsentType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('from', DatePickerType::class, [
                'label' => 'Du',
                'label_attr' => [
                    'class' => 'mr-2',
                ],
                'data' => $builder->getData()['from'],
            ])
            ->add('to', DatePickerType::class, [
                'label' => 'Au',
                'label_attr' => [
                    'class' => 'mr-2',
                ],
                'data' => $builder->getData()['to'],
            ])
            ->add('search', SubmitType::class, [
                'label' => 'Rechercher',
                'attr' => [
                    'class' => 'btn btn-primary mr-2',
                ],
            ]);
    }

    public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults([
            'data_class' => null,
            'attr' => [
                'class' => 'form-inline mb-4',
            ],
        ]);
    }
}
