{% extends "base.html" %}

{% block content %}
    <h1>{{ title or 'Your Assessment Requests' }}</h1>
    <a href="{{ url_for('consultant.new_request') }}" class="btn btn-primary mb-3">Make New Request</a>

    <ul class="nav nav-tabs mb-3">
        <li class="nav-item">
            <a class="nav-link {% if active_tab == 'open' %}active{% endif %}" href="{{ url_for('consultant.manage_open_requests') }}">Pending Requests</a>
        </li>
        <li class="nav-item">
            <a class="nav-link {% if active_tab == 'archived' %}active{% endif %}" href="{{ url_for('consultant.manage_archived_requests') }}">Archived Requests</a>
        </li>
    </ul>

    <table class="table table-striped">
        <thead>
            <tr>
                <th>Assessment</th>
                <th>Quantity</th>
                <th>Cost</th>
                <th>Assigned</th>
                <th>Status</th>
                <th>Request Date</th>
                <th>Admin Notes</th>
            </tr>
        </thead>
        <tbody>
            {% for request in requests %}
            <tr>
                <td>{{ request.assessment.name }}</td>
                <td>{{ request.requested_quantity }}</td>
                <td>₹{{ request.total_cost }}</td>
                <td>{{ request.assigned_count }}</td>
                <td>{{ request.status.capitalize() }}</td>
                <td>{{ request.request_date.strftime('%Y-%m-%d %H:%M') }}</td>
                <td>{{ request.admin_notes if request.admin_notes else 'N/A' }}</td>
            </tr>
            {% else %}
            <tr>
                <td colspan="7" class="text-center">No {{ active_tab == 'open' and 'pending' or 'archived' }} assessment requests found.</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
{% endblock %}
