{% extends "htmx/base.html" %}
{% load widget_tweaks %}

{% block main %}
    <h1>Add ack</h1>

    {% block list_of_acks %}
        <section id="acks">
            <h2>Acks</h2>
            {% for ack in incident.acks %}
                <p>Description: {{ ack.event.description }}</p>
                <p>Expiration: {{ ack.expiration }}</p>
                <p>Acked by: {{ ack.event.actor }}
                    {% if ack.event.actor.groups.exists %}
                        <p>Groups:
                            {% for group in ack.event.actor.groups.all %}
                                {{ group }}
                            {% endfor %}
                        </p>
                    {% endif %}
                </p>
            {% endfor %}
        </section>
    {% endblock list_of_acks %}

    {% block add_ack %}
        <section id="add-ack">

            {% if request.user.is_authenticated %}
                <form action="." method="post">
                    {% csrf_token %}
                    <fieldset class="menu menu-horizontal menu-md border border-secondary items-center gap-4">
                        <legend class="menu-title">Add ack</legend>

                        {% for field in form %}
                            <label class="input input-bordered flex items-center gap-2">
                                {{ field.label }}
                                {{ field|add_class:"appearance-none grow border-none"|append_attr:"placeholder:start writing" }}
                            </label>

                        {% empty %}
                            <p>
                                Something went wrong
                            </p>
                        {% endfor %}
                        <input type="submit" value="Acknowledge" class="btn btn-secondary">
                    </fieldset>
                </form>
            {% else %}
                You need to <a href="/admin/">Log in</a>
            {% endif %}
        </section>
    {% endblock add_ack %}
{% endblock main %}
