{% extends 'htmx_confirmation_modal.html.twig' %}
{% set sendable = valid and attachmentError is null and recipients.eligibleCount > 0 %}
{% block title %}Mail wirklich senden?{% endblock %}
{% block content %}
{% if not valid %}
Betreff und Nachricht müssen ausgefüllt sein, bevor die Mail gesendet werden kann.
{% elseif attachmentError is not null %}
{{ attachmentError }}
{% elseif recipients.eligibleCount == 0 %}
Auf den ausgewählten Einsätzen ist niemand bestätigt eingeteilt, dem geschrieben werden kann.
{% else %}
Die Mail geht an {{ recipients.eligibleCount }} Teamer:innen auf
{{ mailingDto.assignments|length }} {{ mailingDto.assignments|length == 1 ? 'Einsatz' : 'Einsätzen' }}.
{% if houseManagers is not empty %}
In Kopie geht sie an die Hausleitung: {{ include('administrative/assignment_mailing/_house_managers.html.twig') }}.
{% endif %}
Das lässt sich nicht zurücknehmen.
{# a textarea keeps the line breaks of the message intact #}
{% if form._token is defined %}
{{ form_widget(form._token) }}
{% endif %}
{% endif %}
{% endblock %}
{# without a sendable mail there is nothing to confirm, the button only leads back to the draft #}
{% block button_confirm %}{{ sendable ? 'Jetzt senden' : 'Zurück zum Entwurf' }}{% endblock %}
{% block button_attribute %}{% if sendable %}hx-post="{{ path('app_administrative_assignment_mailing_send') }}" hx-include="#mailing-confirm-fields"{% else %}{{ stimulus_action('modal', 'close') }}{% endif %}{% endblock %}