{% extends '@MauticForm/Action/base_form_action.html.twig' %}

{% set footerContent %}
    {% if action.properties.addToLists is defined and action.properties.addToLists is not empty and securityIsGranted('lead:lists:view') %}
        <!-- Add to segments -->
        {% set segments = getEntities('Mautic\\LeadBundle\\Entity\\LeadList', action.properties.addToLists) %}
        {% for segment in segments %}
            {% include '@MauticCore/Helper/_tag.html.twig' with {
                'tags': [{
                    'label': segment.name,
                    'color': 'green',
                    'icon': 'ri-pie-chart-line',
                    'attributes': {
                        'href': path('mautic_segment_action', {'objectAction': 'view', 'objectId': segment.id }),
                        'target': '_blank'
                    }
                }]
            } %}
        {% endfor %}
    {% endif %}

    {% if action.properties.removeFromLists is defined and action.properties.removeFromLists is not empty and securityIsGranted('lead:lists:view') %}
        <!-- Remove from segments -->
        {% set segments = getEntities('Mautic\\LeadBundle\\Entity\\LeadList', action.properties.removeFromLists) %}
        {% for segment in segments %}
            {% include '@MauticCore/Helper/_tag.html.twig' with {
                'tags': [{
                    'label': segment.name,
                    'color': 'red',
                    'icon': 'ri-pie-chart-line',
                    'attributes': {
                        'href': path('mautic_segment_action', {'objectAction': 'view', 'objectId': segment.id }),
                        'target': '_blank'
                    }
                }]
            } %}
        {% endfor %}
    {% endif %}
{% endset %}

{% block action_label %}
    {{ footerContent|raw }}
{% endblock %}
