{% extends '@SyliusUi/Form/theme.html.twig' %}

{% block _sylius_product_attribute_configuration_choices_entry_widget %}
    {% import '@SyliusUi/Macro/flags.html.twig' as flags %}

    <div class="ui styled fluid accordion">
        {% for translation in form %}
            <div data-locale="{{ translation.vars.name }}">
                <div class="title{% if loop.first %} active{% endif %}">
                    <i class="dropdown icon"></i>
                    {{ flags.fromLocaleCode(translation.vars.name) }} {{ translation.vars.name|sylius_locale_name }}
                </div>
                <div class="ui content{% if loop.first %} active{% endif %}">
                    {{ form_widget(translation) }}
                    {{- form_errors(form) -}}
                </div>
            </div>
        {% endfor %}
    </div>
{% endblock %}

{% block sylius_taxon_autocomplete_choice_row %}
    {{ form_row(form, {'remote_url': path('sylius_admin_ajax_taxon_by_name_phrase'), 'load_edit_url': path('sylius_admin_ajax_taxon_by_code')}) }}
{% endblock %}

{% block sylius_product_autocomplete_choice_row %}
    {{ form_row(form, {'remote_url': path('sylius_admin_ajax_product_by_name_phrase'), 'load_edit_url': path('sylius_admin_ajax_product_by_code')}) }}
{% endblock %}

{% block sylius_channel_collection_widget %}
    {% set channelsErrorCount = form.vars.channels_errors_count %}
    <div class="ui top attached tabular menu">
        {% for channelCode, channelForm in form %}
            {% set channelErrorCount = channelsErrorCount[channelCode] ?? 0 %}
            <a class="item{% if loop.first %} active{% endif %}" data-tab="{{ channelForm.vars.full_name }}">
                {{ channelForm.vars.label }}
                {% if channelErrorCount > 0 %}
                    <span class="ui small horizontal circular label" style="background-color: #DB2828">{{ channelErrorCount }}</span>
                {% endif %}
            </a>
        {% endfor %}
    </div>
    {% for channelCode, channelForm in form %}
        <div class="ui bottom attached tab segment{% if loop.first %} active{% endif %}" data-tab="{{ channelForm.vars.full_name }}">
            {{ form_row(channelForm, {'label': false}) }}
        </div>
    {% endfor %}
{% endblock %}

{% block _sylius_channel_channelPriceHistoryConfig_lowestPriceForDiscountedProductsCheckingPeriod_widget %}
    <div class="ui right labeled input">
        {{ form_widget(form) }}
        <div class="ui label">
            {{ 'sylius.ui.days'|trans }}
        </div>
    </div>
{% endblock %}
