<?php

namespace App\Http\Controllers;

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

class DashboardController extends Controller
{
    public function __invoke(Request $request, FrameworkAdapter $adapter): Response
    {
        $user = $request->user();

        $characters = $user->fivem_license
            ? $adapter->findAllByLicense($user->fivem_license)
            : collect();

        return Inertia::render('Player/Dashboard', [
            'characters' => $characters->map->toArray(),
            'donateBalance' => $user->donate_balance,
        ]);
    }
}
