<?php

namespace LaraBB\Group\UI\Web\Handlers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Contracts\View\View;
use Illuminate\View\Factory;
use LaraBB\Group\Actions\Admin\EditAction;
use LaraBB\Group\UI\Web\Requests\Edit;

/**
 * Class EditHandler
 * @package LaraBB\User\UI\Web\Handlers\Admin
 */
class EditHandler extends Controller
{


    /**
     * @param EditAction $editAction
     * @param Factory $view
     */
    public function __construct(private readonly EditAction $editAction, private readonly Factory $view)
    {
    }


    /**
     * @param Edit $request
     * @return View
     */
    public function __invoke(Edit $request): View
    {
        $group = $this->editAction->run($request);

        return $this->view->make('group::admin.create-edit', [
            'group'  => $group,
            'active' => 'groups'
        ]);
    }
}
