<?php

declare(strict_types=1);

namespace KupShop\SalesBundle\Controller;

use KupShop\KupShopBundle\Routing\SimpleTranslatedRoute;
use KupShop\KupShopBundle\Routing\TranslatedRoute;
use KupShop\SalesBundle\View\SalesListView;
use KupShop\SalesBundle\View\SaleView;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class SalesController extends AbstractController
{
    #[SimpleTranslatedRoute('sales-list')]
    public function list(Request $request, SalesListView $view): Response
    {
        return $view->setPage((int) $request->get('page', 1))
            ->getResponse($request);
    }

    #[TranslatedRoute('/#sale-detail#/{id}', requirements: ['id' => '\d+'])]
    public function sale(Request $request, SaleView $view, int $id): Response
    {
        return $view->setSaleId($id)
            ->setSecurityCode($request->get('cf'))
            ->getResponse($request);
    }
}
