<?php

namespace App\Controller\Frontend;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

use App\Repository\GroupeCategorieRepository;

class BasicController extends AbstractController
{
    #[Route('/frontend/basic/search', name: 'frontend_basic_search')]
    public function search(GroupeCategorieRepository $groupeRepository, Request $request): Response
    {
        $user = $this->getUser();

        $paniers = [];
        $total = $nbr = 0;
        if($user){
            $basket = $user->getPanier($request, true);
            $paniers = $basket['paniers'];
            $total = $basket['total'];
            $nbr = $basket['nbr'];
        }
       
        return $this->render('frontend/basic/search.html.twig', [
            'groupes'=>$groupeRepository->findAll(),
            'paniers' => $paniers,
            'total' => $total,
            'nbr'=> $nbr
        ]);
    }
    

    #[Route('/frontend/basic/navbar', name: 'frontend_basic_navbar')]
    public function navbar(): Response
    {
        return $this->render('frontend/basic/navbar.html.twig');
    }

}
