{% trans_default_domain "admin" %}

<div class="grid">

    <div>
        <h2 class="text-base font-semibold leading-6 text-gray-900 dark:text-gray-50">Was gibt es heute zu
            erledigen?</h2>
        <p class="mt-1 text-sm text-gray-500  dark:text-gray-300">Vielleicht helfen Ihnen diese Links
            für den Einstieg.</p>
        <ul role="list"
            class="mt-6 divide-y divide-gray-200 dark:divide-gray-800 border-b border-t border-gray-200 dark:border-gray-800">

            {% if is_granted('ROLE_ADMIN') %}
                {% for edition in editionsWithUncommitedAttendances|default %}
                    <li>
                        <div class="group relative flex items-start space-x-3 py-4">
                            <div class="flex-shrink-0">
                                <span class="inline-flex h-10 w-10 items-center justify-center rounded-lg bg-blue-500">
                                    <span class="h-6 w-6 text-white"><twig:ux:icon name="ph:paper-plane-tilt" /></span>
                                </span>
                            </div>
                            <div class="min-w-0 flex-1">
                                <div class="text-sm font-medium text-gray-900 dark:text-gray-50">
                                    <a href="{{ path('admin_commit_attendances', { alias: edition.alias }) }}">
                                        <span class="absolute inset-0" aria-hidden="true"></span>
                                        Zulosungen festschreiben: <span class="italic">{{ edition.name }}</span>
                                    </a>
                                </div>
                                <p class="text-sm text-gray-500 dark:text-gray-300">Sie müssen die manuellen Zulosungen
                                    noch festschreiben und ggf. die Zulassungsbescheide versenden.</p>
                            </div>
                            <div class="flex-shrink-0 self-center">
                                <twig:ux:icon name="ph:caret-right" class="h-5 w-5 text-gray-400 group-hover:text-gray-500" aria-hidden="true" />
                            </div>
                        </div>
                    </li>
                {% endfor %}
            {% endif %}

            {% if not is_granted('ROLE_ADMIN') %}
                {% for offer in upcomingOffers|filter((offer) => offer.draft and is_granted('view', offer)) %}
                    <li>
                        <div class="group relative flex items-start space-x-3 py-4">
                            <div class="flex-shrink-0">
                                <span class="inline-flex h-10 w-10 items-center justify-center rounded-lg bg-yellow-500">
                                    <twig:ux:icon name="ph:calendar" class="h-6 w-6 text-white" aria-hidden="true" />
                                </span>
                            </div>
                            <div class="min-w-0 flex-1">
                                <div class="text-sm font-medium text-gray-900 dark:text-gray-50">
                                    <a href="{{ path('admin_offers_proof', { uuid: offer.uuid.toBase58 } ) }}">
                                        <span class="absolute inset-0" aria-hidden="true"></span>
                                        „{{ offer.name }}“ jetzt abschließen!</span>
                                    </a>
                                </div>
                                <div class="mt-1 flex items-center gap-x-2 text-sm leading-5 text-gray-500 dark:text-gray-100/40">

                                    {% if offer.dates is not empty %}
                                        {% set startDate = offer.dates|first.begin %}
                                        {% if startDate %}
                                            <time datetime="{{ startDate|date('c') }}">{{ startDate|format_datetime(pattern="E, dd.MM.yyyy HH:mm") }}</time>
                                        {% else %}
                                            <span class="inline-flex items-center text-orange-600">
                                                {{ ux_icon('ph:warning', {class: 'mr-1 size-3.5'}) }}
                                                <span>Termin fehlt</span>
                                            </span>
                                        {% endif %}
                                    {% else %}
                                        <span>Dauerangebot</span>
                                    {% endif %}

                                    <twig:Admin:Badge offer="{{ offer.status|keys|first }}" size="xs" />

                                </div>
                            </div>
                            <div class="flex-shrink-0 self-center">
                                <twig:ux:icon name="ph:caret-right" class="h-5 w-5 text-gray-400 group-hover:text-gray-500" aria-hidden="true" />
                            </div>
                        </div>
                    </li>
                {% endfor %}
            {% endif %}

            {% if not is_granted('ROLE_ADMIN') %}
                {% for offer in upcomingOffers|filter((offer) => offer.published and offer.requiresApplication and offer.isOnlineApplication and is_granted('participants.view', offer))|slice(0, 5) %}
                    <li>
                        <div class="group relative flex items-start space-x-3 py-4">
                            <div class="flex-shrink-0">
                                <span class="inline-flex h-10 w-10 items-center justify-center rounded-lg bg-yellow-500">
                                    <twig:ux:icon name="ph:calendar" class="h-6 w-6 text-white" aria-hidden="true" />
                                </span>
                            </div>
                            <div class="min-w-0 flex-1">
                                <div class="text-sm font-medium text-gray-900 dark:text-gray-50">
                                    <a href="{{ path('admin_offers_participants', { uuid: offer.uuid.toBase58 } ) }}">
                                        <span class="absolute inset-0" aria-hidden="true"></span>
                                        Teilnahmeliste von „{{ offer.name }}“
                                    </a>
                                </div>
                                <div class="mt-1 flex items-center gap-x-2 text-sm leading-5 text-gray-500 dark:text-gray-100/40">

                                    {% if offer.dates is not empty %}
                                        {% set startDate = offer.dates|first.begin %}
                                        {% if startDate %}
                                            <time datetime="{{ startDate|date('c') }}">{{ startDate|format_datetime(pattern="E, dd.MM.yyyy HH:mm") }}</time>
                                        {% else %}
                                            <span class="inline-flex items-center text-orange-600">
                                                {{ ux_icon('ph:warning', {class: 'mr-1 size-3.5'}) }}
                                                <span>Termin fehlt</span>
                                            </span>
                                        {% endif %}
                                    {% else %}
                                        <span>Dauerangebot</span>
                                    {% endif %}

                                    {% if offer.requiresApplication and offer.onlineApplication %}
                                        <p class="flex items-center space-x-1" title="aktuelle Anmeldungen">
                                            <span class="{{ (offer.maxParticipants and offer.attendancesConfirmed|length >= offer.maxParticipants) ? 'text-red-700' : 'text-green-700' }}">
                                                <svg viewBox="0 0 2 2" class="h-2 w-2 fill-current">
                                                    <circle cx="1" cy="1" r="1"/>
                                                </svg>
                                            </span>

                                            <span>
                                                {{ offer.attendancesWithStatuses(["confirmed", "waiting"])|length ~ ' / ' ~ (offer.maxParticipants ?: '∞') ~ '' }}
                                            </span>

                                            {% if offer.attendancesWaiting|length %}
                                                <span title="nicht-zugeteilte Teilnehmende"
                                                      class="mt-0.5 text-orange-600 w-4 h-4"><twig:ux:icon name="ph:warning" /></span>
                                            {% endif %}
                                        </p>
                                    {% endif %}
                                </div>
                            </div>
                            <div class="flex-shrink-0 self-center">
                                <twig:ux:icon name="ph:caret-right" class="h-5 w-5 text-gray-400 group-hover:text-gray-500" aria-hidden="true" />
                            </div>
                        </div>
                    </li>
                {% endfor %}
            {% endif %}

            {% for edition in editions.findWithActiveTask('host_editing_stage') %}
                {% if is_granted('offer.create', edition) %}
                    <li>
                        <div class="group relative flex items-start space-x-3 py-4">
                            <div class="flex-shrink-0">
                                <span class="inline-flex h-10 w-10 items-center justify-center rounded-lg bg-yellow-500">
                                    <twig:ux:icon name="ph:calendar" class="h-6 w-6 text-white" aria-hidden="true" />
                                </span>
                            </div>
                            <div class="min-w-0 flex-1">
                                <div class="text-sm font-medium text-gray-900 dark:text-gray-50">
                                    <a href="{{ path('admin_offers_new_in_edition', { edition: edition.alias }) }}" data-turbo-frame="slideover">
                                        <span class="absolute inset-0" aria-hidden="true"></span>
                                        Neue Veranstaltung in <span class="italic">{{ edition.name }}</span>
                                    </a>
                                </div>
                                <p class="text-sm text-gray-500 dark:text-gray-300">Erstellen Sie jetzt eine neue
                                    Veranstaltung für <span
                                            class="italic">{{ edition.name }}</span>!</p>
                            </div>
                            <div class="flex-shrink-0 self-center">
                                <twig:ux:icon name="ph:caret-right" class="h-5 w-5 text-gray-400 group-hover:text-gray-500" aria-hidden="true" />
                            </div>
                        </div>
                    </li>
                {% endif %}
            {% endfor %}

            {% if is_granted('ROLE_ADMIN') %}
                {% for edition in editionsWithFinalizedOffers %}
                    <li>
                        <div class="group relative flex items-start space-x-3 py-4">
                            <div class="flex-shrink-0">
                                <span class="inline-flex h-10 w-10 items-center justify-center rounded-lg bg-orange-500">
                                    <twig:ux:icon name="ph:check-fat" class="h-6 w-6 text-white" />
                                </span>
                            </div>
                            <div class="min-w-0 flex-1">
                                <div class="text-sm font-medium text-gray-900 dark:text-gray-50">
                                    <a href="{{ path('admin_offers_review', { alias: edition.alias }) }}">
                                        <span class="absolute inset-0" aria-hidden="true"></span>
                                        Angebote freischalten: <span class="italic">{{ edition.name }}</span>
                                    </a>
                                </div>
                                <p class="text-sm text-gray-500 dark:text-gray-300">Es gibt Veranstaltungen, die noch
                                    freigegeben werden müssen.</p>
                            </div>
                            <div class="flex-shrink-0 self-center">
                                <twig:ux:icon name="ph:caret-right" class="h-5 w-5 text-gray-400 group-hover:text-gray-500" aria-hidden="true" />
                            </div>
                        </div>
                    </li>
                {% endfor %}
            {% endif %}

            {% if is_granted('ROLE_ADMIN') and messagesWithError|length > 0 %}
                <li>
                    <div class="group relative flex items-start space-x-3 py-4">
                        <div class="flex-shrink-0">
                            <span class="inline-flex h-10 w-10 items-center justify-center rounded-lg bg-red-600 text-white">
                                <twig:ux:icon name="ph:warning" class="h-6 w-6" />
                            </span>
                        </div>
                        <div class="min-w-0 flex-1">
                            <div class="text-sm font-medium text-gray-900 dark:text-gray-50">
                                <a href="{{ path('email_delivery_errors') }}">
                                    <span class="absolute inset-0" aria-hidden="true"></span>
                                    Bei {{ messagesWithError|length }} E-Mails kam es in den letzten 30 Tagen zu Zustellproblemen
                                </a>
                            </div>
                            <p class="text-sm text-gray-500 dark:text-gray-300">Prüfen Sie, welche E-Mail-Adressen Fehler produzieren.</p>
                        </div>
                        <div class="flex-shrink-0 self-center">
                            <twig:ux:icon name="ph:caret-right" class="h-5 w-5 text-gray-400 group-hover:text-gray-500" aria-hidden="true" />
                        </div>
                    </div>
                </li>
            {% endif %}

            {% if is_granted('ROLE_ADMIN') %}
                {% for edition in editionsWithWaitingAttendances %}
                    <li>
                        <div class="group relative flex items-start space-x-3 py-4">
                            <div class="flex-shrink-0">
                                <span class="inline-flex h-10 w-10 items-center justify-center rounded-lg bg-pink-500">
                                    <twig:ux:icon name="ph:arrows-clockwise" class="h-6 w-6 text-white" />
                                </span>
                            </div>
                            <div class="min-w-0 flex-1">
                                <div class="text-sm font-medium text-gray-900 dark:text-gray-50">
                                    <a href="{{ path('admin_editions_assign', { alias: edition.alias }) }}">
                                        <span class="absolute inset-0" aria-hidden="true"></span>
                                        Plätze zuteilen: <span class="italic">{{ edition.name }}</span>
                                    </a>
                                </div>
                                <p class="text-sm text-gray-500 dark:text-gray-300">Es gibt Teilnehmende, denen noch
                                    Plätze zugeteilt werden müssen.</p>
                            </div>
                            <div class="flex-shrink-0 self-center">
                                <twig:ux:icon name="ph:caret-right" class="h-5 w-5 text-gray-400 group-hover:text-gray-500" aria-hidden="true" />
                            </div>
                        </div>
                    </li>
                {% else %}
                    <li>
                        <div class="group relative flex items-start space-x-3 py-4">
                            <div class="flex-shrink-0">
                                <span class="inline-flex h-10 w-10 items-center justify-center rounded-lg bg-green-600">
                                    <twig:ux:icon name="ph:check" class="h-6 w-6 text-white" />
                                </span>
                            </div>
                            <div class="min-w-0 flex-1">
                                <div class="text-sm font-medium text-gray-900 dark:text-gray-50">
                                    Alle Plätze zugeteilt!
                                </div>
                                <p class="text-sm text-gray-500 dark:text-gray-300">Super Job! Es gibt gerade
                                    niemanden, der noch auf Zuteilung wartet!</p>
                            </div>
                        </div>
                    </li>
                {% endfor %}
            {% endif %}

            {% if is_granted('ROLE_ADMIN') and editions.findUpcoming is empty %}
                <li>
                    <div class="group relative flex items-start space-x-3 py-4">
                        <div class="flex-shrink-0">
                            <span class="inline-flex h-10 w-10 items-center justify-center rounded-lg bg-pink-500">
                                <twig:ux:icon name="ph:globe" class="h-6 w-6 text-white" aria-hidden="true" />
                            </span>
                        </div>
                        <div class="min-w-0 flex-1">
                            <div class="text-sm font-medium text-gray-900 dark:text-gray-50">
                                <a href="{{ path('admin_editions_create') }}">
                                    <span class="absolute inset-0" aria-hidden="true"></span>
                                    Neue Ferienpass-Saison erstellen
                                </a>
                            </div>
                            <p class="text-sm text-gray-500 dark:text-gray-300">Es schaut so aus, als wäre es Zeit für
                                einen neuen
                                Ferienpass.</p>
                        </div>
                        <div class="flex-shrink-0 self-center">
                            <twig:ux:icon name="ph:caret-right" class="h-5 w-5 text-gray-400 group-hover:text-gray-500" aria-hidden="true" />
                        </div>
                    </div>
                </li>
            {% endif %}

            {% if is_granted('ROLE_ADMIN') and expiredParticipants is not empty %}
                <li>
                    <div class="group relative flex items-start space-x-3 py-4">
                        <div class="flex-shrink-0">
                            <span class="inline-flex h-10 w-10 items-center justify-center rounded-lg bg-red-500">
                                <span class="h-6 w-6 text-white" aria-hidden="true">
                                    {{ ux_icon('ph:trash') }}
                                </span>
                            </span>
                        </div>
                        <div class="min-w-0 flex-1">
                            <div class="text-sm font-medium text-gray-900 dark:text-gray-50">
                                <a href="{{ path('admin_erase_data') }}">
                                    <span class="absolute inset-0" aria-hidden="true"></span>
                                    Daten löschen
                                </a>
                            </div>
                            <p class="text-sm text-gray-500 dark:text-gray-300">Es ist Zeit, die personenbezogenen Daten
                                der Teilnehmenden zu löschen.</p>
                        </div>
                        <div class="flex-shrink-0 self-center">
                            <twig:ux:icon name="ph:caret-right" class="h-5 w-5 text-gray-400 group-hover:text-gray-500" aria-hidden="true" />
                        </div>
                    </div>
                </li>
            {% endif %}

        </ul>
    </div>
    {#
    <div>
        <h2 class="text-base font-semibold leading-6 text-gray-900">Sind Sie auf Kurs?</h2>
        <p class="mt-1 text-sm text-gray-500 dark:text-gray-300">Hier können Sie sehen, was zuletzt alles passiert ist.</p>
        <ul role="list" class="mt-6 divide-y divide-gray-200 border-b border-t border-gray-200">
            <li class="py-4">
                <div class="flex items-center gap-x-3">
                    <img src="https://images.unsplash.com/photo-1519244703995-f4e0f30006d5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80"
                         alt="" class="h-6 w-6 flex-none rounded-full bg-gray-800">
                    <h3 class="flex-auto truncate text-sm font-semibold leading-6 text-gray-900">Michael Foster</h3>
                    <time datetime="2023-01-23T11:00" class="flex-none text-xs text-gray-500">1h</time>
                </div>
                <p class="mt-3 truncate text-sm text-gray-500 dark:text-gray-300">Pushed to <span class="text-gray-700">ios-app</span>
                    (<span class="font-mono text-gray-700">2d89f0c8</span> on <span class="text-gray-700">main</span>)
                </p>
            </li>
            <li class="py-4">
                <div class="flex items-center gap-x-3">
                    <img src="https://images.unsplash.com/photo-1517841905240-472988babdf9?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80"
                         alt="" class="h-6 w-6 flex-none rounded-full bg-gray-800">
                    <h3 class="flex-auto truncate text-sm font-semibold leading-6 text-gray-900">Lindsay Walton</h3>
                    <time datetime="2023-01-23T09:00" class="flex-none text-xs text-gray-500">3h</time>
                </div>
                <p class="mt-3 truncate text-sm text-gray-500 dark:text-gray-300">Pushed to <span class="text-gray-700">mobile-api</span> (<span
                            class="font-mono text-gray-700">249df660</span> on <span class="text-gray-700">main</span>)
                </p>
            </li>
            <li class="py-4">
                <div class="flex items-center gap-x-3">
                    <img src="https://images.unsplash.com/photo-1438761681033-6461ffad8d80?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80"
                         alt="" class="h-6 w-6 flex-none rounded-full bg-gray-800">
                    <h3 class="flex-auto truncate text-sm font-semibold leading-6 text-gray-900">Courtney Henry</h3>
                    <time datetime="2023-01-23T00:00" class="flex-none text-xs text-gray-500">12h</time>
                </div>
                <p class="mt-3 truncate text-sm text-gray-500 dark:text-gray-300">Pushed to <span class="text-gray-700">ios-app</span>
                    (<span class="font-mono text-gray-700">11464223</span> on <span class="text-gray-700">main</span>)
                </p>
            </li>
            <li class="py-4">
                <div class="flex items-center gap-x-3">
                    <img src="https://images.unsplash.com/photo-1438761681033-6461ffad8d80?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80"
                         alt="" class="h-6 w-6 flex-none rounded-full bg-gray-800">
                    <h3 class="flex-auto truncate text-sm font-semibold leading-6 text-gray-900">Courtney Henry</h3>
                    <time datetime="2023-01-21T13:00" class="flex-none text-xs text-gray-500">2d</time>
                </div>
                <p class="mt-3 truncate text-sm text-gray-500 dark:text-gray-300">Pushed to <span
                            class="text-gray-700">tailwindui.com</span> (<span
                            class="font-mono text-gray-700">dad28e95</span> on <span class="text-gray-700">main</span>)
                </p>
            </li>
            <li class="py-4">
                <div class="flex items-center gap-x-3">
                    <img src="https://images.unsplash.com/photo-1519244703995-f4e0f30006d5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80"
                         alt="" class="h-6 w-6 flex-none rounded-full bg-gray-800">
                    <h3 class="flex-auto truncate text-sm font-semibold leading-6 text-gray-900">Michael Foster</h3>
                    <time datetime="2023-01-18T12:34" class="flex-none text-xs text-gray-500">5d</time>
                </div>
                <p class="mt-3 truncate text-sm text-gray-500 dark:text-gray-300">Pushed to <span
                            class="text-gray-700">relay-service</span> (<span
                            class="font-mono text-gray-700">624bc94c</span> on <span class="text-gray-700">main</span>)
                </p>
            </li>
        </ul>

    </div> #}
</div>