<?php

namespace App\Http\Controllers\SuperAdmin;

use App\Enums\UserRole;
use App\Http\Controllers\Controller;
use App\Services\SuperAdmin\PlatformAdminService;
use Illuminate\Http\Request;
use Illuminate\View\View;

class UserController extends Controller
{
    public function index(Request $request, PlatformAdminService $platform): View
    {
        return view('super-admin.users.index', [
            'users' => $platform->users($request),
            'roles' => ['all' => 'All roles'] + collect(UserRole::cases())
                ->mapWithKeys(fn (UserRole $role) => [$role->value => str($role->value)->headline()->toString()])
                ->all(),
            'filters' => $request->only(['q', 'role']),
        ]);
    }
}
