<?php

namespace KupShop\OrderingBundle\Controller;

use KupShop\KupShopBundle\Routing\TranslatedRoute;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class ActivateOrderController extends AbstractController
{
    /**
     * @TranslatedRoute("/#activate_order#/{type}/")
     */
    public function activateOrderAction(string $type): RedirectResponse
    {
        // Pokud nemam modul reklamace a ani vratky, tak vratim 404
        if (!findModule(\Modules::RECLAMATIONS) && !findModule(\Modules::RETURNS)) {
            throw new NotFoundHttpException('Module RECLAMATIONS or RETURNS not found!');
        }

        switch ($type) {
            case 'reclamations':
                return new RedirectResponse(
                    path('kupshop_reclamations_reclamations_createreclamationlogin'),
                    301
                );
            case 'returns':
                return new RedirectResponse(
                    path('kupshop_returns_returns_createreturnslogin'),
                    301
                );
        }

        return new RedirectResponse('/');
    }
}
