{% extends "base.html" %}
{% load static %}

{% block title %}Manage Users - AI ML Operations{% endblock %}

{% block content %}
<div class="section">
    <div class="container">
        <h1 class="section-title" style="text-align: left;">Manage Users</h1>

        {% if messages %}
        {% for message in messages %}
        <p style="margin-bottom: 1rem; color: {% if message.tags == 'error' %}#ff6666{% else %}var(--primary-color){% endif %};">
            {{ message }}
        </p>
        {% endfor %}
        {% endif %}

        <div class="card" style="max-width: 600px; margin-bottom: 2rem;">
            <h2 style="font-size: 1.1rem; margin-bottom: 1rem;">Set User Type</h2>
            <form method="post">
                {% csrf_token %}
                {{ form.as_p }}
                <button type="submit" class="btn" style="margin-top: 1rem;">Update User Type</button>
            </form>
        </div>

        <div class="table-responsive">
            <table class="table">
                <thead>
                    <tr>
                        <th>Username</th>
                        <th>Name</th>
                        <th>Type</th>
                    </tr>
                </thead>
                <tbody>
                    {% for u in users %}
                    <tr>
                        <td>{{ u.username }}</td>
                        <td>{{ u.get_full_name|default:"—" }}</td>
                        <td>{{ u.profile.get_user_type_display|default:"Client" }}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}
