<?php

namespace App\Form;

use App\Entity\MemberCase;
use App\Entity\ReferralSource;
use App\Enums\CaseLevel;
use App\Enums\County;
use App\Enums\Case\ReferralType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class MemberCaseFormType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $docs = $options['docs'];

        $builder
            ->add('caseNumber', TextType::class, [
                'required' => true
            ])
            ->add('firstName', TextType::class, [
                'required' => true
            ])
            ->add('lastName', TextType::class, [
                'required' => true
            ])
            ->add('referralType', EnumType::class, [
                'class' => ReferralType::class
            ])
            ->add('admitDate', null, [
                'widget' => 'single_text',
                'required' => true,
            ])
            ->add('closeDate', null, [
                'widget' => 'single_text',
            ])
            ->add('dcsCaseId', TextType::class, [
                'required' => true
            ])
            ->add('insurance')
            ->add('medicaid')
            ->add('caseEmail')
            ->add('level', EnumType::class, [
                'class' => CaseLevel::class,
            ])
            ->add('referralSource', EntityType::class, [
                'class' => ReferralSource::class,
                'choice_label' => 'name',
            ])
            ->add('referralSource2', EntityType::class, [
                'class' => ReferralSource::class,
                'choice_label' => 'name',
            ])
            ->add('address')
            ->add('address2')
            ->add('city')
            ->add('state')
            ->add('zip')
            ->add('county', EnumType::class, [
                'class' => County::class,
            ])
        ;
    }

    public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults([
            'data_class' => MemberCase::class,
            'docs' => [],
            'csrf_protection' => true,
            'csrf_field_name' => '_token',
            'csrf_token_id' => 'member_case',
        ]);
    }
}
