<?php

namespace App\Modules\HR\Recruitment\Controllers;

use App\Http\Controllers\Controller;
use App\Modules\HR\Recruitment\Services\RecruitmentDashboardService;
use Illuminate\Http\Request;
use Illuminate\View\View;

class RecruitmentDashboardPageController extends Controller
{
    public function __construct(
        private readonly RecruitmentDashboardService $dashboard,
    ) {}

    public function index(Request $request): View
    {
        abort_unless($request->user()?->can('recruitment.view'), 403);
        $tenantId = (int) $request->user()->tenant_id;
        abort_if($tenantId < 1, 403);

        return view(
            'pages.hr.recruitment.dashboard.index',
            $this->dashboard->build($tenantId),
        );
    }
}
