<?php

namespace LaraBB\Torrent\UI\Web\Handlers;

use Illuminate\Contracts\View\View;
use Illuminate\View\Factory;
use LaraBB\Torrent\Actions\UploadAction;
use LaraBB\Torrent\UI\Web\Requests\UploadRequest;

/**
 *
 */
class UploadHandler
{
    /**
     * @param UploadAction $uploadAction
     * @param Factory $view
     */
    public function __construct(
        private readonly UploadAction $uploadAction,
        private readonly Factory $view
    ) {

    }

    /**
     * @param UploadRequest $request
     * @param string $uuid
     * @return View
     */
    public function __invoke(UploadRequest $request, string $uuid = ''): View
    {
        return $this->view->make('torrent::upload', $this->uploadAction->run($request, $uuid));
    }
}
