<?php

/*
 * This file is part of the Serenity package.
 *
 * (c) CP Creation <web@cpcreation.fr>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CpCreation\VitiCore\Bridge\Symfony\Bundle\Controller\Admin;

use CpCreation\VitiCore\Shop\Repository\ShippingAutoRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\ExpressionLanguage\Expression;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;

#[Route('/shipping-auto-price')]
#[IsGranted(new Expression("is_granted('ROLE_ADMIN')"))]
final class ShippingAutoController extends AbstractController
{
    public function __construct(
        private readonly ShippingAutoRepository $shippingAutoRepository,
    ) {
    }

    #[Route('', name: 'admin_shipping_auto')]
    public function index(): Response
    {
        $prices = $this->shippingAutoRepository->findOrder();

        return $this->render('@CpCreationVitiCore/admin/shipping/auto/index.html.twig', [
            'items' => $prices,
        ]);
    }
}
