{% extends "@FerienpassAdmin/layout/modalBase.html.twig" %}
{% trans_default_domain 'admin' %}

{% block main %}
    <div class="space-y-6">
        <div>
            <h3 class="text-lg font-semibold leading-6 text-gray-900 dark:text-white">
                {% if category.uuid %}Kategorie bearbeiten{% else %}Neue Kategorie{% endif %}
            </h3>
        </div>
        <div class="mt-4">
            {{ form_start(form, {action: category.uuid ? path('admin_tools_settings_category_edit', {uuid: category.uuid.toBase58}) : path('admin_tools_settings_category_create')}) }}
                <div class="space-y-4">
                    {{ form_row(form.name) }}
                    {{ form_row(form.alias) }}
                </div>
                <div class="mt-5 sm:mt-6 flex justify-end gap-x-3">
                    <twig:Admin:Button command="close" commandfor="admin-modal-dialog">Abbrechen</twig:Admin:Button>
                    <twig:Admin:Button type="submit" variant="primary">Speichern</twig:Admin:Button>
                </div>
            {{ form_end(form) }}
        </div>
    </div>
{% endblock %}

{% block category_row %}
    <li id="category-{{ category.uuid }}" class="flex justify-between gap-x-6 py-6">
        <div class="font-medium text-gray-900 dark:text-white">{{ category.name }} <span class="text-xs text-gray-400">({{ category.alias }})</span></div>
        <a href="{{ path('admin_tools_settings_category_edit', {uuid: category.uuid.toBase58}) }}" data-turbo-frame="modal" class="font-semibold text-indigo-600 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-300">Bearbeiten</a>
    </li>
{% endblock %}

{% block category_saved_stream %}
    {% if is_new %}
        <turbo-stream action="append" target="offer-categories-list">
            <template>
                {{ block('category_row') }}
            </template>
        </turbo-stream>
    {% else %}
        <turbo-stream action="replace" target="category-{{ category.uuid }}">
            <template>
                {{ block('category_row') }}
            </template>
        </turbo-stream>
    {% endif %}
    <turbo-stream action="update" target="modal">
        <template></template>
    </turbo-stream>
{% endblock %}
