<?php

namespace App\Controller;

use App\Entity\Account;
use App\Entity\AccountResetPasswordRequest;
use App\Entity\Event;
use App\Form\RequestPasswordConfirmType;
use App\Form\RequestPasswordRequestType;
use App\Repository\EventRepository;
use App\Service\ResetPassword\Event\ResetPasswordConfirmEvent;
use App\Service\ResetPassword\Event\ResetPasswordEvent;
use Doctrine\ORM\EntityManagerInterface;
use Psr\EventDispatcher\EventDispatcherInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Twig\Environment;

class EventsController extends AbstractController
{

    #[Route(path: '/events', name: 'app_events', options: ['sitemap' => true], methods: ['GET'])]
    public function index(EventRepository $eventRepository): Response
    {
        return $this->render('event.twig',[
            'events' => $eventRepository->findBy([],['startAt' => 'DESC']),
        ]);
    }
    #[Route(path: '/events/{id}', name: 'app_event_details', options: ['sitemap' => false], methods: ['GET'])]
    public function eventDetails(?Event $event): Response
    {
        if(is_null($event)) {
            return $this->redirectToRoute('app_events');
        }
        return $this->render('event_view.twig',[
            'event' => $event,
        ]);

    }
}
