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

sylius_shop_account_live_component:
    path: '/_components/{_live_component}/{_live_action}'
    defaults:
        _live_action: 'get'

sylius_shop_account_order:
    resource: "@SyliusShopBundle/Resources/config/routing/account/order.yml"
    prefix: /orders

sylius_shop_account_address_book:
    resource: "@SyliusShopBundle/Resources/config/routing/account/address_book.yml"
    prefix: /address-book

sylius_shop_account_root:
    path: /
    methods: [GET]
    defaults:
        _controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction
        route: sylius_shop_account_dashboard
        permanent: true

sylius_shop_account_dashboard:
    path: /dashboard
    methods: [GET]
    defaults:
        _controller: sylius.controller.customer::showAction
        _sylius:
            template: "@SyliusShop/account/dashboard.html.twig"
            repository:
                method: find
                arguments:
                    - "expr:service('sylius.context.customer').getCustomer()"

sylius_shop_account_profile_update:
    path: /profile/edit
    methods: [GET, PUT]
    defaults:
        _controller: sylius.controller.customer::updateAction
        _sylius:
            template: "@SyliusShop/account/profile_update.html.twig"
            form: Sylius\Bundle\ShopBundle\Form\Type\CustomerProfileType
            repository:
                method: find
                arguments:
                    - "expr:service('sylius.context.customer').getCustomer()"
            redirect:
                route: sylius_shop_account_profile_update
                parameters: {}

sylius_shop_account_change_password:
    path: /change-password
    methods: [GET, POST]
    defaults:
        _controller: sylius.controller.shop_user::changePasswordAction
        _sylius:
            form: Sylius\Bundle\ShopBundle\Form\Type\UserChangePasswordType
            template: "@SyliusShop/account/change_password.html.twig"
            redirect: sylius_shop_account_dashboard
