<?php

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

use Illuminate\Contracts\View\View;
use Illuminate\View\Factory;
use LaraBB\Profile\Actions\Admin\EditAction;
use LaraBB\Profile\UI\Web\Requests\Admin\Edit;

/**
 * Class EditHandler
 * @package LaraBB\Profile\UI\Web\Handlers\Admin
 */
class EditHandler
{
    /**
     * EditHandler constructor.
     * @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
    {
        $user = $this->editAction->run($request);

        return $this->view->make('profile::admin.create-edit', [
            'user'      => $user,
            'active'    => 'users',
            'subactive' => 'profile'
        ]);
    }
}
