<?php

declare(strict_types=1);

/*
 * This file is part of the Ferienpass package.
 *
 * (c) Richard Henkenjohann <richard@ferienpass.online>
 *
 * For more information visit the project website <https://ferienpass.online>
 * or the documentation under <https://docs.ferienpass.online>.
 */

namespace Ferienpass\AdminBundle\Form;

use Ferienpass\CoreBundle\Entity\PageConfig;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class PageConfigType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('pageTitle', TextType::class, [
                'label' => 'Seitentitel',
                'help' => 'Wird als Suffix im <title>-Tag des Admin-Panels verwendet.',
                'required' => false,
            ])
            ->add('adminEmail', EmailType::class, [
                'label' => 'Admin-E-Mail-Adresse',
                'help' => 'Wird als Absender für System-E-Mails verwendet.',
                'required' => false,
            ])
            ->add('adminEmailName', TextType::class, [
                'label' => 'Admin-E-Mail-Name',
                'help' => 'Wird als Name für den Absender verwendet.',
                'required' => false,
            ])
            ->add('replyToEmail', EmailType::class, [
                'label' => 'Antwort-E-Mail-Adresse',
                'help' => 'Wenn gesetzt, wird diese Adresse als Antwortadresse für System-E-Mails verwendet.',
                'required' => false,
            ])
            ->add('replyToName', TextType::class, [
                'label' => 'Antwort-E-Mail-Name',
                'help' => 'Wird als Name für die Antwortadresse verwendet.',
                'required' => false,
            ])
            ->add('language', ChoiceType::class, [
                'label' => 'Sprache',
                'choices' => [
                    'Deutsch' => 'de',
                    'English' => 'en',
                ],
                'required' => false,
            ])
            ->add('dateFormat', ChoiceType::class, [
                'label' => 'Datumsformat',
                'choices' => [
                    'DD.MM.YYYY' => 'd.m.Y',
                    'YYYY-MM-DD' => 'Y-m-d',
                    'MM/DD/YYYY' => 'm/d/Y',
                ],
                'required' => false,
            ])
            ->add('timezone', ChoiceType::class, [
                'label' => 'Zeitzone',
                'choices' => array_combine(\DateTimeZone::listIdentifiers(), \DateTimeZone::listIdentifiers()),
                'required' => false,
            ])
            ->add('colorPrimary', TextType::class, [
                'label' => 'Primärfarbe',
                'help' => 'Hex-Farbe (z. B. #008edf). Daraus wird die komplette Farbskala (primary-50 bis primary-900) zur Laufzeit abgeleitet — ohne eigenen Build.',
                'required' => false,
            ])
        ;
    }

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