<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <!-- Land a logged-in customer on the new dealer dashboard by default. -->
    <type name="Magento\Customer\Controller\Account\LoginPost">
        <plugin name="zhik_portal_login_dashboard_redirect" type="Zhik\Portal\Plugin\LoginRedirect"/>
    </type>
    <!-- Skip the empty logout-success shell — send logout straight to login. -->
    <type name="Magento\Customer\Controller\Account\LogoutSuccess">
        <plugin name="zhik_portal_logout_to_login" type="Zhik\Portal\Plugin\LogoutSuccessRedirect"/>
    </type>
    <!-- Expose postpaid eligibility + the "save cart" shortcut to the checkout payment step
         (window.checkoutConfig.postpaid / .saveCart). -->
    <type name="Magento\Checkout\Model\CompositeConfigProvider">
        <arguments>
            <argument name="configProviders" xsi:type="array">
                <item name="zhik_portal_postpaid" xsi:type="object">Zhik\Portal\Model\Checkout\PostpaidConfigProvider</item>
                <item name="zhik_portal_save_cart" xsi:type="object">Zhik\Portal\Model\Checkout\SaveCartConfigProvider</item>
            </argument>
        </arguments>
    </type>
    <!-- Carry the "save cart" eligibility into the minicart's cart customer-data section. -->
    <type name="Magento\Checkout\CustomerData\Cart">
        <plugin name="zhik_portal_minicart_save_cart" type="Zhik\Portal\Plugin\Checkout\MinicartSaveCartData"/>
    </type>
    <!-- The standalone cart page is disabled for the portal. Block the page and
         point the minicart's cart links at the dashboard instead. -->
    <type name="Magento\Checkout\Controller\Cart\Index">
        <plugin name="zhik_portal_disable_cart_page" type="Zhik\Portal\Plugin\Checkout\DisableCartPage"/>
    </type>
    <type name="Magento\Checkout\Block\Cart\Sidebar">
        <plugin name="zhik_portal_minicart_cart_url" type="Zhik\Portal\Plugin\Checkout\MinicartCartUrl"/>
    </type>
</config>
