{% extends "repapp/base.html" %}
{% load crispy_forms_tags %}
{% block title %}
    - Reparateur
{% endblock title %}
{% block page_title %}
    Reparateur
{% endblock page_title %}
{% block content %}
    <p>
        <a href="{% url 'member_settings' %}" class="btn btn-primary">Einstellungen</a>
    </p>
    <hr class="mt-0 mb-4">
    <h1 class="mt-2">Repair-Cafés</h1>
    <table class="table">
        <thead>
            <tr>
                <th scope="col">Datum</th>
                <th scope="col">Ort</th>
                <th scope="col">Teilnahmen zugesagt?</th>
                <th scope="col"></th>
            </tr>
        </thead>
        <tbody>
            {% for cafe in cafes %}
                <tr>
                    <td>{{ cafe.event_date|date:"l" }}, {{ cafe.event_date|date }}</td>
                    <td>{{ cafe.location }}</td>
                    <td>
                        {% if cafe.accepted %}
                            Ja
                        {% else %}
                            Nein
                        {% endif %}
                    </td>
                    <td>
                        {% if cafe.accepted %}
                            <a href="{% url 'repa_cafe_decline' cafe.pk %}" class="btn btn-primary">absagen</a>
                        {% else %}
                            <a href="{% url 'repa_cafe_accept' cafe.pk %}" class="btn btn-primary">teilnehmen</a>
                        {% endif %}
                    </td>
                </tr>
            {% empty %}
                <tr>
                    <td colspan="4">Es gibt keine Repair-Cafés.</td>
                </tr>
            {% endfor %}
        </tbody>
    </table>
    <hr class="mt-0 mb-4">
    <h1 class="mt-2">Geräte</h1>
    <table class="table">
        <thead>
            <tr>
                <th scope="col">Art des Geräts</th>
                <th scope="col">Hersteller & Modell/Typ</th>
                <th scope="col">Repair-Café</th>
                <th scope="col">Ort</th>
                <th scope="col">mir zugeordnet?</th>
                <th scope="col"></th>
            </tr>
        </thead>
        <tbody>
            {% for device in devices %}
                <tr>
                    <td>{{ device.device }}</td>
                    <td>{{ device.manufacturer }}</td>
                    <td>{{ device.cafe.event_date|date:"l" }}, {{ device.cafe.event_date|date }}</td>
                    <td>{{ device.cafe.location }}</td>
                    <td>
                        {% if device.assigned %}
                            Ja
                        {% else %}
                            Nein
                        {% endif %}
                    </td>
                    <td>
                        <a href="{% url 'repa_view_device' device.pk %}" class="btn btn-primary">Details</a>
                    </td>
                </tr>
            {% empty %}
                <tr>
                    <td colspan="4">Es gibt kein Geräte.</td>
                </tr>
            {% endfor %}
        </tbody>
    </table>
{% endblock content %}
