{% extends 'base/base.html' %}
{% block title %}Transaction History - CryptoSignals Pro{% endblock %}

{% block content %}
<div class="container-fluid">
    <h1 class="page-title">Transaction History</h1>
    
    <div class="card">
        <div class="card-body">
            {% if page_obj %}
            <div class="table-responsive">
                <table class="table">
                    <thead>
                        <tr>
                            <th class="custom-text-muted">Type</th>
                            <th class="custom-text-muted">Amount</th>
                            <th class="custom-text-muted">Status</th>
                            <th class="custom-text-muted">Reference</th>
                            <th class="custom-text-muted">Date</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for transaction in page_obj %}
                        <tr>
                            <td class="custom-text-muted">{{ transaction.get_transaction_type_display }}</td>
                            <td class="{% if transaction.transaction_type == 'DEPOSIT' or transaction.transaction_type == 'REFERRAL_BONUS' %}custom-text-success{% else %}custom-text-danger{% endif %}">
                                {% if transaction.transaction_type == 'DEPOSIT' or transaction.transaction_type == 'REFERRAL_BONUS' %}+{% else %}-{% endif %}
                                ${{ transaction.amount|floatformat:2 }}
                            </td>
                            <td>
                                <span class="badge badge-{{ transaction.status|lower }}">{{ transaction.get_status_display }}</span>
                            </td>
                            <td class="custom-text-muted"><small>{{ transaction.reference_id|default:"-" }}</small></td>
                            <td class="custom-text-muted">{{ transaction.created_at|date:"M d, Y H:i" }}</td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
            
            {% if page_obj.has_other_pages %}
            <nav>
                <ul class="pagination justify-content-center">
                    {% if page_obj.has_previous %}
                    <li class="page-item"><a class="page-link" href="?page={{ page_obj.previous_page_number }}">Previous</a></li>
                    {% endif %}
                    <li class="page-item active"><span class="page-link">Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}</span></li>
                    {% if page_obj.has_next %}
                    <li class="page-item"><a class="page-link" href="?page={{ page_obj.next_page_number }}">Next</a></li>
                    {% endif %}
                </ul>
            </nav>
            {% endif %}
            {% else %}
            <p class="text-center custom-text-muted py-4">No transactions yet.</p>
            {% endif %}
        </div>
    </div>
</div>
{% endblock %}
