<?php

/*
 * This file is part of the VITICORE2 package.
 *
 * (c) CP Creation <web@cpcreation.fr>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CpCreation\VitiCore\Bridge\Symfony\Bundle\Form\Site;

use CpCreation\AltchaBundle\Form\AltchaType;
use CpCreation\VitiCore\Bridge\Symfony\Bundle\Altcha\VitiCoreAltchaProtection;
use CpCreation\VitiCore\Marketing\DTO\ProductReviewReportSubmission;
use CpCreation\VitiCore\Marketing\Model\ProductReviewReport;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

final class ProductReviewReportType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('reason', ChoiceType::class, [
                'label' => 'marketing.review_report.form.reason',
                'choices' => [
                    'marketing.review_report.reason.inappropriate' => ProductReviewReport::REASON_INAPPROPRIATE,
                    'marketing.review_report.reason.personal_data' => ProductReviewReport::REASON_PERSONAL_DATA,
                    'marketing.review_report.reason.unrelated' => ProductReviewReport::REASON_UNRELATED,
                    'marketing.review_report.reason.suspected_fraud' => ProductReviewReport::REASON_SUSPECTED_FRAUD,
                    'marketing.review_report.reason.other' => ProductReviewReport::REASON_OTHER,
                ],
                'placeholder' => 'marketing.review_report.form.reason_placeholder',
            ])
            ->add('comment', TextareaType::class, [
                'label' => 'marketing.review_report.form.comment',
                'help' => 'marketing.review_report.form.comment_help',
                'required' => false,
                'attr' => ['rows' => 5, 'maxlength' => 1000],
            ])
            ->add('captcha', AltchaType::class, [
                'scope' => VitiCoreAltchaProtection::scopeFor(self::class),
            ])
        ;
    }

    public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults([
            'data_class' => ProductReviewReportSubmission::class,
            'translation_domain' => 'messages',
            'csrf_token_id' => 'product_review_report',
        ]);
    }
}
