{% extends '@CoreShopFrontend/layout.html.twig' %}
{% import '@CoreShopFrontend/Common/Macro/currency.html.twig' as currency %}

{% block content %}

    {% include '@CoreShopFrontend/Common/flash_messages.html.twig' %}

    {% if share_link is defined and share_link %}
        <div class="input-group mb-3">
            <input {{ coreshop_test_html_attribute('share-wishlist-link') }} type="text" class="form-control" readonly="readonly" id="link" value="{{ share_link }}" >
            <div class="input-group-append">
                <button class="btn btn-outline-success copy-to-clipboard" data-copied-text="{{ 'coreshop.ui.copied'|trans }}" data-target="link" type="button" id="button-addon2">{{ 'coreshop.ui.copy'|trans }}</button>
            </div>
        </div>

    {% endif %}

    {% if storage_list.hasItems %}
    <div class="table-responsive shopping-wishlist-table">
        <table class="table table-bordered" {{ coreshop_test_html_attribute('wishlist-items') }}>
            <thead>
            <tr>
                <td class="text-center">
                    {{ 'coreshop.ui.image'|trans }}
                </td>
                <td class="text-center">
                    {{ 'coreshop.ui.product_details'|trans }}
                </td>
                <td class="text-center">
                    {{ 'coreshop.ui.price'|trans }}
                </td>
                {% if not is_shared_list %}
                <td class="text-center">

                </td>
                {% endif %}
            </tr>
            </thead>
            <tbody>
            {% for item in storage_list.items %}
                {% set product = item.product %}
                {% set productUrl = pimcore_object_path(product) %}
                <tr class="shopping-wishlist-item" {{ coreshop_test_html_attribute('wishlist-item-row', product.name) }}>
                    <td class="text-center">
                        {% if item.product and item.product.image is pimcore_asset_image %}
                            <a class="" href="{{ productUrl }}">
                                {{ item.product.image|pimcore_image_thumbnail_html('coreshop_productCart', {'imgAttributes': {'class': 'img-fluid'}, 'alt': item.product.name, 'title': item.product.name}) }}
                            </a>
                        {% endif %}
                    </td>
                    <td class="text-center">
                        <a href="{{ productUrl }}" {{ coreshop_test_html_attribute('wishlist-item-name', product.name) }}>
                            {{ product.name }}
                        </a>
                    </td>
                    <td class="text-right wishlist-item-price">
                        {{ currency.getPrice(product) }}
                    </td>
                    {% if not is_shared_list %}
                    <td class="text-center">
                        <a
                                href="{{ path('coreshop_wishlist_remove', {item: item.id|coreshop_string}) }}"
                                title="{{ 'coreshop.ui.remove'|trans }}"
                                class="btn btn-danger tool-tip"
                                data-id="{{ item.id }}"
                                {{ coreshop_test_html_attribute('wishlist-remove-button', product.name) }}
                        >
                            <i class="fa fa-times-circle"></i>
                        </a>
                    </td>
                    {% endif %}
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
    {% else %}
        <p {{ coreshop_test_html_attribute('wishlist-empty') }}>{{ 'coreshop.ui.wishlist_empty'|trans }}</p>
    {% endif %}
    <br/>
{% endblock %}
