# This file is a part of the Sylius package.
# (c) Sylius Sp. z o.o.

sylius_shop_checkout_start:
    path: /
    methods: [GET]
    defaults:
        _controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction
        route: sylius_shop_checkout_address

sylius_shop_checkout_address:
    path: /address
    methods: [GET, PUT]
    defaults:
        _controller: sylius.controller.order::updateAction
        _sylius:
            event: address
            flash: false
            template: "@SyliusShop/Checkout/address.html.twig"
            form:
                type: Sylius\Bundle\CoreBundle\Form\Type\Checkout\AddressType
                options:
                    customer: expr:service('sylius.context.customer').getCustomer()
            repository:
                method: findCartForAddressing
                arguments:
                    - "expr:service('sylius.context.cart').getCart().getId()"
            state_machine:
                graph: sylius_order_checkout
                transition: address

sylius_shop_checkout_select_shipping:
    path: /select-shipping
    methods: [GET, PUT]
    defaults:
        _controller: sylius.controller.order::updateAction
        _sylius:
            event: select_shipping
            flash: false
            template: "@SyliusShop/Checkout/selectShipping.html.twig"
            form: Sylius\Bundle\CoreBundle\Form\Type\Checkout\SelectShippingType
            repository:
                method: findCartForSelectingShipping
                arguments:
                    - "expr:service('sylius.context.cart').getCart().getId()"
            state_machine:
                graph: sylius_order_checkout
                transition: select_shipping

sylius_shop_checkout_select_payment:
    path: /select-payment
    methods: [GET, PUT]
    defaults:
        _controller: sylius.controller.order::updateAction
        _sylius:
            event: payment
            flash: false
            template: "@SyliusShop/Checkout/selectPayment.html.twig"
            form: Sylius\Bundle\CoreBundle\Form\Type\Checkout\SelectPaymentType
            repository:
                method: findCartForSelectingPayment
                arguments:
                    - "expr:service('sylius.context.cart').getCart().getId()"
            state_machine:
                graph: sylius_order_checkout
                transition: select_payment

sylius_shop_checkout_complete:
    path: /complete
    methods: [GET, PUT]
    defaults:
        _controller: sylius.controller.order::updateAction
        _sylius:
            event: complete
            flash: false
            template: "@SyliusShop/Checkout/complete.html.twig"
            repository:
                method: findCartForSummary
                arguments:
                    - "expr:service('sylius.context.cart').getCart().getId()"
            state_machine:
                graph: sylius_order_checkout
                transition: complete
            redirect:
                route: sylius_shop_order_pay
                parameters:
                    tokenValue: resource.tokenValue
            form:
                type: Sylius\Bundle\CoreBundle\Form\Type\Checkout\CompleteType
                options:
                    validation_groups: 'sylius_checkout_complete'
