<?php

namespace KupShop\ReclamationsElninoBundle\Controller;

use KupShop\KupShopBundle\Routing\TranslatedRoute;
use KupShop\OrderingBundle\Util\UserContent\UserContent;
use KupShop\ReclamationsElninoBundle\View\CreateReclamationView;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;

class ReclamationsController extends AbstractController
{
    /**
     * @TranslatedRoute("/#reclamations#/#create_reclamation#/")
     */
    public function createReclamationAction(CreateReclamationView $view, Request $request)
    {
        if ($request->get('nextStep')) {
            $view->handleStep_products($request->get('items'), $request->get('reclamation_items'));
        }

        return $view->getResponse();
    }

    /**
     * @TranslatedRoute("/#reclamations#/#create_reclamation#/{id_order}/", requirements={"id_order"="\d+"})
     */
    public function createReclamationOrderAction(CreateReclamationView $view, Request $request, $id_order)
    {
        if ($request->get('nextStep')) {
            $view->handleStep_products($request->get('items'), $request->get('reclamation_items'));
        } else {
            $view->setStep('products')->setOrderId($id_order);
        }

        return $view->getResponse();
    }

    /**
     * @TranslatedRoute("/#reclamations#/#create_reclamation#/#reclamation_summary#/")
     */
    public function createReclamationSummaryAction(Request $request, CreateReclamationView $view, UserContent $userContent)
    {
        $view->setStep('summary');
        if ($request->get('nextStep')) {
            $user_content = $userContent->getData('reclamation');
            $view->handleStep_reclamationSummary(
                $request->get('delivery'),
                $request->get('bank_account'),
                $request->get('preferred_handle_type'),
                $request->get('note'),
                $user_content
            );
        }

        return $view->getResponse();
    }
}
