{% extends '@ChillMain/Workflow/workflow_view_send_public_layout.html.twig' %}

{% block css %}
    {{ parent() }}
    {{ encore_entry_link_tags('mod_document_download_button') }}
{% endblock %}

{% block js %}
    {{ parent() }}
    {{ encore_entry_script_tags('mod_document_download_button') }}
{% endblock %}

{% block title %}{{ 'workflow.public_link.title'|trans }} - {{ title }}{% endblock %}

{% block public_content %}
    <h1>{{ 'workflow.public_link.shared_doc'|trans }}</h1>

    {% set previous = send.entityWorkflowStepChained.previous %}
    {% if previous is not null %}
        {% if previous.transitionBy is not null %}
            <p>{{ 'workflow.public_link.doc_shared_by_at_explanation'|trans({'byUser': previous.transitionBy|chill_entity_render_string( { 'at_date': previous.transitionAt } ), 'at': previous.transitionAt }) }}</p>
        {% else %}
            <p>{{ 'workflow.public_link.doc_shared_automatically_at_explanation'|trans({'at': previous.transitionAt}) }}</p>
        {% endif %}
    {% endif %}

    <div class="row g-3">
        <div class="col-xs-12 col-sm-6 col-md-4">
            <div class="card">
                <div class="card-body">
                    <h2 class="card-title">{{ title }}</h2>
                    <h3>{{ 'workflow.public_link.main_document'|trans }}</h3>

                    <ul class="record_actions slim small">
                        <li>
                            {{ storedObject|chill_document_download_only_button(storedObject.title(), false) }}
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        {% for attachment in attachments %}
            <div class="col-xs-12 col-sm-6 col-md-4">
                <div class="card">
                    <div class="card-body">
                        <h2 class="card-title">{{ attachment.proxyStoredObject.title }}</h2>
                        <h3>{{ 'workflow.public_link.attachment'|trans }}</h3>

                        <ul class="record_actions slim small">
                            <li>
                                {{ attachment.proxyStoredObject|chill_document_download_only_button(storedObject.title(), false) }}
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        {% endfor %}
    </div>
{% endblock %}
