{% extends "base.html" %}
{% block content %}
<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title">Users</h3>
                </div>
                <div class="card-body">
                    <div class="row mb-3">
                        <div class="col-md-12">
                            <form method="get">
                                <div class="row">
                                    <div class="col-md-3">
                                        <input type="text" name="q" class="form-control" placeholder="Search..." value="{{ request.GET.q }}">
                                    </div>
                                    <div class="col-md-2">
                                        <select name="role" class="form-control">
                                            <option value="">Role</option>
                                            {% for role in roles %}
                                            <option value="{{ role.0 }}" {% if request.GET.role == role.0 %}selected{% endif %}>{{ role.1 }}</option>
                                            {% endfor %}
                                        </select>
                                    </div>
                                    <div class="col-md-1">
                                        <button type="submit" class="btn btn-primary">Filter</button>
                                    </div>
                                    <div class="col-md-6 text-right">
                                        <a href="#" class="btn btn-success">Add New User</a>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                    <table class="table table-bordered">
                        <thead>
                            <tr>
                                <th>Username</th>
                                <th>Email</th>
                                <th>Role</th>
                                <th>Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for user in users %}
                            <tr>
                                <td>{{ user.username }}</td>
                                <td>{{ user.email }}</td>
                                <td>{{ user.get_role_display }}</td>
                                <td>
                                    <a href="#" class="btn btn-sm btn-primary">View</a>
                                </td>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
