<?php

namespace App\Modules\HR\EmployeeSelfService\Controllers;

use App\Http\Controllers\Controller;
use App\Modules\HR\EmployeeSelfService\Services\EmployeeSelfProfileService;
use App\Modules\HR\EmployeeSelfService\Services\SelfEmployeeContextService;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\View\View;

class MeProfileController extends Controller
{
    use AuthorizesRequests;

    public function __construct(
        private readonly SelfEmployeeContextService $context,
        private readonly EmployeeSelfProfileService $profiles,
    ) {}

    public function show(): View
    {
        $employee = $this->context->employee();
        $this->authorize('view', $employee);
        $payload = $this->profiles->profilePayload(request()->user());

        return view('pages.me.profile', $payload);
    }
}
