<!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
{% block sw_sales_channel_modal %}
<sw-modal
    class="sw-sales-channel-modal"
    :title="$tc(modalTitle)"
    @modal-close="onCloseModal"
>
    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_sales_channel_modal_grid %}
    <sw-sales-channel-modal-grid
        v-if="!detailType"
        :product-streams-exist="productStreamsExist"
        :product-streams-loading="productStreamsLoading"
        :add-channel-action="addChannelAction"
        @grid-detail-open="onGridOpenDetails"
        @grid-channel-add="onAddChannel"
    />
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_sales_channel_modal_detail %}
    <sw-sales-channel-modal-detail
        v-else
        :detail-type="detailType"
    />
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_sales_channel_modal_footer %}
    <template #modal-footer>
        <a
            href="#"
            class="sw-sales-channel-modal__footer_left"
            @click.prevent="openRoute({ name: 'sw.sales.channel.list' })"
        >
            {{ $tc('sw-sales-channel.general.manageSalesChannels') }}
        </a>

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_sales_channel_modal_footer_detail_actions %}
        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_sales_channel_modal_footer_back %}
        <sw-button
            v-if="detailType"
            size="small"
            @click.prevent="detailType = false"
        >
            {{ $tc('sw-sales-channel.modal.buttonBack') }}
        </sw-button>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_sales_channel_modal_footer_add_channel %}
        <sw-button
            v-if="detailType"
            v-tooltip="{
                message: $tc('sw-sales-channel.modal.messageNoProductStreams'),
                showOnDisabledElements: true,
                disabled: !addChannelAction.disabled(detailType.id)
            }"
            class="sw-sales-channel-modal__add-sales-channel-action"
            variant="primary"
            size="small"
            :is-loading="addChannelAction.loading(detailType.id)"
            :disabled="addChannelAction.disabled(detailType.id)"
            @click="onAddChannel(detailType.id)"
        >
            {{ $tc('sw-sales-channel.modal.buttonAddChannel') }}
        </sw-button>
        {% endblock %}
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_sales_channel_modal_footer_actions %}
        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_sales_channel_modal_footer_cancel %}
        <sw-button
            v-if="!detailType"
            size="small"
            @click="onCloseModal"
        >
            {{ $tc('global.default.cancel') }}
        </sw-button>
        {% endblock %}
        {% endblock %}
    </template>
    {% endblock %}
</sw-modal>
{% endblock %}
