<?php

/*
 * This file is part of the Serenity 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\Admin;

use Craue\FormFlowBundle\Form\FormFlow;
use Craue\FormFlowBundle\Form\FormFlowInterface;

final class PaymentMethodFlow extends FormFlow
{
    public function __construct(
        private readonly array $paymentMethods = [],
    ) {}

    protected function loadStepsConfig(): array
    {
        return [
            [
                'label' => 'Methode',
                'form_type' => 'CpCreation\VitiCore\Bridge\Symfony\Bundle\Form\Admin\PaymentMethodStep1Type',
                'form_options' => [
                    'validation_groups' => ['step1'],
                    'payment_methods' => $this->paymentMethods,
                ],
                'skip' => function ($estimatedCurrentStepNumber, FormFlowInterface $flow) {
                    return null !== $flow->getFormData()->getMethod();
                },
            ],
            [
                'label' => 'Config',
                'form_type' => 'CpCreation\VitiCore\Bridge\Symfony\Bundle\Form\Admin\PaymentMethodStep2Type',
                'form_options' => [
                    'validation_groups' => ['step2'],
                ],
            ],
        ];
    }
}
