{% extends 'generic/base.html' %}

{% block content %}
    <h2>Cid Groups</h2>
    <p>
    <a href="{% url 'generic:cid_group_create' %}">Create new group</a>
    </p>
    {% for group in groups %}
        <p><a href="{% url 'generic:cid_group_detail' group.pk %}"><h4>{{group.name}}</h4></a>
            <button class="small-url-button" data-url="{% url 'generic:group_email' pk=group.pk %}
            ">Email candidate details</button>
            <button class="small-url-button" data-url="{% url 'generic:group_email_resend' pk=group.pk %}
                ">Resend candidate details</button>
            <button class="small-url-button" data-url="{% url 'generic:group_email_results' pk=group.pk %}
            ">Email candidate results</button>
            <button class="small-url-button" data-url="{% url 'generic:group_email_results_resend' pk=group.pk %}
            ">Resend candidate results</button>
            <button class="small-url-button" data-url="{% url 'generic:cid_group_update' pk=group.pk %}
            ">Edit</button>
            <button class="small-url-button" data-url="{% url 'generic:cid_group_delete' pk=group.pk %}
            ">Delete</button>
        </p>
    {% endfor %}

    <script type="text/javascript">

        $(".small-url-button").click((evt) => {
            window.location = evt.currentTarget.dataset.url;
        })

    </script>

    {% if view_all %}
        <a href="{% url 'generic:cid_group_view' %}">View active</a>
    {% else %}
        <a href="{% url 'generic:cid_group_view_all' %}">View all</a>
    {% endif %}
{% endblock %}
