<?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\Offer;

use Ferienpass\AdminBundle\Form\AsOfferFormType;
use Ferienpass\CoreBundle\Settings\PageConfigManager;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\OptionsResolver\OptionsResolver;

#[AsOfferFormType]
class ApplicationDeadline extends AbstractType
{
    public function __construct(private readonly PageConfigManager $pageConfigManager)
    {
    }

    public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults([
            'view_timezone' => $this->pageConfigManager->getPageConfig()->getTimezone(),
            'help' => 'offers.help.applicationDeadline',
            'widget' => 'single_text',
            // The property is a \DateTimeImmutable; the form type's default input
            // would hand the setter a \DateTime.
            'input' => 'datetime_immutable',
        ]);
    }

    public function getParent(): string
    {
        return DateTimeType::class;
    }
}
