<?php

namespace App\Http\Controllers\SuperAdmin;

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

class SupportTicketController extends Controller
{
    public function index(Request $request, PlatformAdminService $platform): View
    {
        return view('super-admin.support.index', [
            'tickets' => $platform->tickets($request),
            'stats' => $platform->ticketStats(),
            'statuses' => ['all' => 'All statuses'] + collect(SupportTicketStatus::cases())
                ->mapWithKeys(fn (SupportTicketStatus $status) => [$status->value => str($status->value)->headline()->toString()])
                ->all(),
            'filters' => $request->only(['q', 'status']),
        ]);
    }
}
