<?php

declare(strict_types=1);

namespace App\Application\Api;

use App\Application\LiveComponents\UserRegistration\UserRegistrationFormDefinition;
use App\Framework\Attributes\Route;
use App\Framework\Http\Method;
use App\Framework\LiveComponents\FormBuilder\MultiStepFormComponent;
use App\Framework\LiveComponents\ValueObjects\ComponentId;
use App\Framework\Meta\MetaData;
use App\Framework\Router\Result\ViewResult;

/**
 * Demo Controller für LiveComponent FormBuilder
 */
final readonly class LiveComponentDemoController
{
    #[Route('/demo/livecomponent-form', method: Method::GET)]
    public function showMultiStepForm(): ViewResult
    {
        // Form Definition erstellen
        $formDefinition = UserRegistrationFormDefinition::create();

        // Component erstellen
        $component = new MultiStepFormComponent(
            id: ComponentId::generate('user-registration'),
            formDefinition: $formDefinition
        );

        return new ViewResult(
            template: 'pages/livecomponent-demo',
            metaData: MetaData::create(
                title: 'LiveComponent Multi-Step Form Demo',
                description: 'Beispiel für die Integration von LiveComponent + FormBuilder'
            ),
            data: [
                'page_title' => 'LiveComponent Multi-Step Form Demo',
                'registration_form' => $component,
            ]
        );
    }
}
