{% extends "layout.html" %}

{% block content %}
<div class="admin-container">
    <h1>Edit User: {{ user.username }}</h1>
        
    <form method="POST" action="{{ url_for('edit_user', user_id=user.id) }}" class="user-form">
        <div class="form-group">
            <label for="username">Username</label>
            <input type="text" id="username" name="username" class="form-control" value="{{ user.username }}" required>
        </div>
        
        <div class="form-group">
            <label for="email">Email</label>
            <input type="email" id="email" name="email" class="form-control" value="{{ user.email }}" required>
        </div>
        
        <div class="form-group">
            <label for="password">New Password (leave blank to keep current)</label>
            <input type="password" id="password" name="password" class="form-control">
        </div>
        
        <div class="form-group">
            <label for="role">Role</label>
            <select id="role" name="role" class="form-control">
                {% for role in roles %}
                <option value="{{ role.name }}" {% if user.role == role %}selected{% endif %}>
                    {{ role.name.replace('_', ' ').title() }}
                </option>
                {% endfor %}
            </select>
        </div>
        
        <div class="form-group">
            <label for="team_id">Team</label>
            <select id="team_id" name="team_id" class="form-control">
                <option value="">-- No Team --</option>
                {% for team in teams %}
                <option value="{{ team.id }}" {% if user.team_id == team.id %}selected{% endif %}>
                    {{ team.name }}
                </option>
                {% endfor %}
            </select>
        </div>
        
        
        <div class="form-group">
            <button type="submit" class="btn btn-primary">Update User</button>
            <a href="{{ url_for('admin_users') }}" class="btn btn-secondary">Cancel</a>
        </div>
    </form>
</div>
{% endblock %}