<?php

namespace App\Http\Controllers\Admin;

use App\FiveM\Contracts\FrameworkAdapter;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;

/**
 * Distinct from PlayerManagerController: Player Manager treats a citizen ID
 * as an account to moderate (money, detail drill-down); this page is the
 * flat character roster admins scan when looking for a specific character
 * by name/job rather than by player account.
 */
class CharacterManagerController extends Controller
{
    public function index(Request $request, FrameworkAdapter $adapter): Response
    {
        $characters = $adapter->paginateCharacters(50, $request->string('search')->value() ?: null);

        return Inertia::render('Admin/Characters/Index', [
            'characters' => $characters->through(fn ($c) => $c->toArray()),
            'search' => $request->string('search')->value(),
        ]);
    }
}
