{% extends "@FerienpassAdmin/layout/list.html.twig" %}

{% block list %}
{{ component('Admin:SearchableQueryableList', {
        qb: qb,
        filterType: filterType,
        routeName: app.current_route,
        routeParameters: app.current_route_parameters|merge(app.request.query.all),
        searchable: searchable|default([]),
        headline: (headline == "#{translationPrefix}.#{action}.title") ? "#{translationPrefix}.title"|trans : headline,
        createUrl: createUrl|default(null),
        viewKey: 'admin_consents',
        viewPathPrefix: '/admin/einwilligungen',
        exports: exports|default([]),
        config: {
            title: '{{ item.user.name|default("Unbekannt") }}',
            info: [
                '{{ "consent.#{item.type|default("")}"|trans({}, "admin") }} {{ item.type|default("") == "edition_agreement_letter" and item.edition|default ? item.edition.name|default("") : "" }}',
                '{{ item.createdAt|default ? item.createdAt|date("d.m.Y H:i") : "" }}',
            ],
            columns: {
            user: '
{% if item.user|default %}
<span class="inline-flex items-center justify-center h-6 w-6 rounded-full bg-gray-400">
    <span class="text-xs font-medium leading-none text-white">{{ item.user.firstname|first|upper ~ item.user.lastname|first|upper }}</span>
</span>
<span>
    {{ item.user.firstname|default("") ~ " " ~ item.user.lastname|default("") }}
</span>
{% else %}
-
{% endif %}
{% if item.participant|default %}
    <span class="font-normal">({{ item.participant.name|default("") }})</span>
{% endif %}
',
            type: '{{ "consent.#{item.type|default("")}"|trans({}, "admin") }} {{ item.type|default("") == "edition_agreement_letter" and item.edition|default ? item.edition.name|default("") : "" }}',
            date: '{{ item.createdAt|default ? item.createdAt|date("d.m.Y H:i") : "" }}',
            status: '
{% trans_default_domain "admin" %}

{% if item.revoked %}
    {{ component("Admin:Badge", { color: "red", size: "sm", class: "-ml-2", content: "consents.status.revoked" }) }}
{% elseif item.decision != 1 %}
    {{ component("Admin:Badge", { color: "red", size: "sm", class: "-ml-2", content: "consents.status.disagreed" }) }}
{% else %}
    {{ component("Admin:Badge", { color: "green", size: "sm", class: "-ml-2", content: "consents.status.agreed" }) }}
{% endif %}
',
        }
    }}) }}
{% endblock %}
