<?php

namespace App\Livewire\Dashboard;

use Livewire\Component;
use App\Models\User;

class DashboardMain extends Component
{
    public function render()
    {
        $user = auth()->user();
        $data = [];

        if ($user->hasAnyRole(['admin', 'superadmin', 'gerente', 'jefe_soporte'])) {
            $data['totalUsuarios']   = User::count();
            $data['usuariosActivos'] = User::where('is_active', true)->count();
        }

        return view('livewire.dashboard.dashboard-main', [
            'data'     => $data,
            'userRole' => $user->getRoleNames()->first() ?? 'sin-rol',
        ]);
    }
}
