<?php

namespace App\Modules\Operations\Controllers;

use App\Http\Controllers\Controller;
use App\Modules\Operations\Models\OperationalControlEvent;
use App\Modules\Operations\Services\OperationalControlCenterDashboardService;
use Illuminate\View\View;

class OperationalControlCenterPageController extends Controller
{
    public function __construct(
        private readonly OperationalControlCenterDashboardService $dashboard,
    ) {}

    public function index(): View
    {
        $this->authorize('viewAny', OperationalControlEvent::class);
        $tenantId = (int) auth()->user()?->tenant_id;
        abort_if($tenantId === 0, 403);

        return view('pages.operations.control-center.index', $this->dashboard->assemble($tenantId));
    }
}
