<?php

declare(strict_types=1);

namespace App\Controller\Frontend\Profile;

use App\Http\Response;
use App\Http\ServerRequest;
use App\Locale;
use Psr\Http\Message\ResponseInterface;

class IndexAction
{
    public function __invoke(
        ServerRequest $request,
        Response $response
    ): ResponseInterface {
        $router = $request->getRouter();

        return $request->getView()->renderVuePage(
            response: $response,
            component: 'Vue_Account',
            id: 'account',
            title: __('My Account'),
            props: [
                'userUrl' => (string)$router->named('api:frontend:account:me'),
                'changePasswordUrl' => (string)$router->named('api:frontend:account:password'),
                'twoFactorUrl' => (string)$router->named('api:frontend:account:two-factor'),
                'apiKeysApiUrl' => (string)$router->named('api:frontend:api-keys'),
                'supportedLocales' => Locale::SUPPORTED_LOCALES,
            ]
        );
    }
}
