<?php

namespace App\Http\Controllers;

use App\Queries\EventRegistrationQuery;
use Illuminate\View\View;

class MyEventsController extends Controller
{
    public function __construct(private EventRegistrationQuery $registrationQuery) {}

    public function index(): View
    {
        $tab = request('tab', 'upcoming');

        $registrations = $this->registrationQuery->forUser(
            auth()->user(),
            $tab === 'past' ? ['past' => true] : ['upcoming' => true],
        );

        return view('pages.events.my-events', [
            'registrations' => $registrations,
            'tab' => $tab,
        ]);
    }
}
