{% extends 'adminapp/master.html' %}

{% block content %}
<div class="container mt-4">
    <h2 class="mb-4">Manage Payments</h2>
    
    <table class="table table-bordered">
        <thead class="thead-dark">
            <tr>
                <th>#</th>
                <th>User</th>
                <th>Amount</th>
                <th>Payment Method</th>
                <th>Status</th>
                <th>Date</th>
                <th>Actions</th>
            </tr>
        </thead>
        <tbody>
            {% for payment in payments %}
            <tr>
                <td>{{ forloop.counter }}</td>
                <td>{{ payment.user.username }}</td>
                <td>${{ payment.amount }}</td>
                <td>{{ payment.payment_method }}</td>
                <td>
                    <span class="badge {% if payment.status == 'Completed' %}badge-success{% elif payment.status == 'Pending' %}badge-warning{% else %}badge-danger{% endif %}">
                        {{ payment.status }}
                    </span>
                </td>
                <td>{{ payment.date }}</td>
                <td>
                    {% if payment.status == 'Pending' %}
                    <a href="{% url 'approve_payment' payment.id %}" class="btn btn-success btn-sm">Approve</a>
                    {% endif %}
                    <a href="{% url 'delete_payment' payment.id %}" class="btn btn-danger btn-sm">Delete</a>
                </td>
            </tr>
            {% empty %}
            <tr>
                <td colspan="7" class="text-center">No payments found.</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
{% endblock %}
