<?php

namespace App\Application\Auth;

use App\Framework\Attributes\Route;
use App\Framework\Auth\Auth;
use App\Framework\CommandBus\CommandBus;
use App\Framework\Http\Method;
use App\Framework\Router\Result\ViewResult;

class ShowLogin
{
    public function __construct(
        private CommandBus $commandBus,
    )
    {
    }

    #[Auth]
    #[Route('/login')]
    public function __invoke()
    {
        return new ViewResult('loginform');

    }

    #[Auth]
    #[Route('/login', Method::POST)]
    public function login(LoginRequest $request)
    {
        $login = new LoginUser($request->email, $request->password);

        $this->commandBus->dispatch($login);

        dd($request);

    }
}
