<?php

namespace LaraBB\User\Actions;

use JetBrains\PhpStorm\ArrayShape;
use LaraBB\Invite\Tasks\FindTask as FindInviteTask;
use LaraBB\User\UI\Web\Requests\Register\Show;

/**
 * Class RegisterPageAction
 * @package LaraBB\User\Actions
 */
class RegisterPageAction
{
    /**
     * RegisterPageAction constructor.
     * @param FindInviteTask $findInviteTask
     */
    public function __construct(private readonly FindInviteTask $findInviteTask)
    {
    }

    /**
     * @param Show $request
     * @return array
     */
    #[ArrayShape(['code' => "mixed"])]
    public function run(Show $request): array
    {
        return [
            'code' => $this->findInviteTask->byCode($request->route('code'))
        ];
    }
}
