<?php

namespace App\Application\Contact;

use App\Framework\Attributes\Route;
use App\Framework\CommandBus\CommandBus;
use App\Framework\Http\Method;
use App\Framework\Meta\Keywords;
use App\Framework\Meta\StaticPageMetaResolver;
use App\Framework\Router\ActionResult;
use App\Framework\Router\Result\ContentNegotiationResult;
use App\Framework\Router\Result\ViewResult;

final readonly class ShowContact
{
    #[Route(path: '/kontakt', name: 'contact')]
    public function __invoke(): ViewResult
    {
        return new ViewResult('contact',
            new StaticPageMetaResolver(
                'Kontakt',
                'Kontaktseite!',
                Keywords::fromStrings('Kontakt', 'Welt')
            )(),);
    }

    #[Route(path: '/kontakt', method: Method::POST)]
    public function senden(ContactRequest $request, CommandBus $commandBus): ActionResult
    {

        $command = new StoreContact(
            $request->email,
            $request->name,
            $request->subject ?? 'Kein Betreff angegeben',
            $request->message,
        );

        $commandBus->dispatch($command);

        dd($request);

        return new ContentNegotiationResult(

        );
        #return new ViewResult('contact-senden');
    }
}
