<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

/** @var $block \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar */
?>
<div class="customer-current-activity-inner">
    <h4 class="customer-activity-title"><?= /* @escapeNotVerified */ __('Customer\'s Activities') ?></h4>
    <div class="create-order-sidebar-container">
    <?= $block->getChildHtml('top_button') ?>
    <?php foreach ($block->getLayout()->getChildBlocks($block->getNameInLayout()) as $_alias => $_child): ?>
        <?php if ($_alias != 'top_button' && $_alias != 'bottom_button'): ?>
            <?php if ($block->canDisplay($_child)): ?>
                <div class="order-sidebar-block" id="order-sidebar_<?= /* @escapeNotVerified */ $_alias ?>">
                    <?= $block->getChildHtml($_alias) ?>
                </div>
            <?php endif; ?>
        <?php endif; ?>
    <?php endforeach; ?>
    <?= $block->getChildHtml('bottom_button') ?>
    </div>
</div>
<script>
require([
    "prototype",
    "Magento_Catalog/catalog/product/composite/configure"
], function(){

    function addSidebarCompositeListType() {
        productConfigure.addListType('sidebar', {
            urlFetch: '<?= /* @escapeNotVerified */ $block->getUrl('sales/order_create/configureProductToAdd') ?>',
            urlConfirm: '<?= /* @escapeNotVerified */ $block->getUrl('sales/order_create/addConfigured') ?>'
        });
        productConfigure.addListType('sidebar_wishlist', {
            urlFetch: '<?= /* @escapeNotVerified */ $block->getUrl('customer/wishlist_product_composite_wishlist/configure') ?>',
            urlConfirm: '<?= /* @escapeNotVerified */ $block->getUrl('sales/order_create/addConfigured') ?>'
        });
    }

    if (typeof(sidebarListTypeWorkedOn) == 'undefined') {
        sidebarListTypeWorkedOn = false;
    }
    if (!sidebarListTypeWorkedOn) {
        if (typeof(productConfigure) == 'undefined') {
            Event.observe(window, 'load',  function(){
                setTimeout(addSidebarCompositeListType, 10);
            })
        } else {
            addSidebarCompositeListType();
        }
        sidebarListTypeWorkedOn = true;
    }

    window.addSidebarCompositeListType = addSidebarCompositeListType;
});
</script>
