<?php

declare(strict_types=1);

namespace MauticPlugin\DealFlowBundle\Form\Type;

use MauticPlugin\DealFlowBundle\Entity\InboundWebhookSource;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

final class InboundWebhookSourceType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('name', TextType::class, [
                'label' => 'Connection name',
            ])
            ->add('sourceKey', TextType::class, [
                'label' => 'Endpoint key',
            ])
            ->add('secret', TextType::class, [
                'label' => 'Signing secret',
                'attr' => [
                    'autocomplete' => 'off',
                ],
            ])
            ->add('isActive', CheckboxType::class, [
                'label' => 'Active',
                'required' => false,
            ]);
    }

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