{% extends "base.html" %}
{% block title %}Edit User{% endblock %}
{% block content %}
<div class="container mt-4">
    <h2>Edit User</h2>
    <form method="post" class="row g-3">
        {% csrf_token %}
        <div class="col-md-6">
            <label for="username" class="form-label">Username</label>
            <input type="text" class="form-control" id="username" name="username" value="{{ user.username }}" readonly>
        </div>
        <div class="col-md-6">
            <label for="email" class="form-label">Email</label>
            <input type="email" class="form-control" id="email" name="email" value="{{ user.email }}" required>
        </div>
        <div class="col-md-6">
            <label for="first_name" class="form-label">First Name</label>
            <input type="text" class="form-control" id="first_name" name="first_name" value="{{ user.first_name }}" required>
        </div>
        <div class="col-md-6">
            <label for="last_name" class="form-label">Last Name</label>
            <input type="text" class="form-control" id="last_name" name="last_name" value="{{ user.last_name }}" required>
        </div>
        <div class="col-md-6">
            <label for="role" class="form-label">Role</label>
            <select class="form-select" id="role" name="role">
                <option value="ADMIN" {% if user.role == 'ADMIN' %}selected{% endif %}>Admin</option>
                <option value="STAFF" {% if user.role == 'STAFF' %}selected{% endif %}>Staff</option>
                <option value="CUSTOMER" {% if user.role == 'CUSTOMER' %}selected{% endif %}>Customer</option>
                <option value="RIDER" {% if user.role == 'RIDER' %}selected{% endif %}>Rider</option>
            </select>
        </div>
        <div class="col-md-6 d-flex align-items-center">
            <div class="form-check mt-2">
                <input class="form-check-input" type="checkbox" id="banned" name="banned" {% if user.banned %}checked{% endif %}>
                <label class="form-check-label" for="banned">Banned</label>
            </div>
        </div>
        <div class="col-md-6">
            <label for="password" class="form-label">Password (leave blank to keep current)</label>
            <input type="password" class="form-control" id="password" name="password">
        </div>
        <div class="col-12">
            <button type="submit" class="btn btn-primary">Update User</button>
            <a href="{% url 'user-management' %}" class="btn btn-secondary">Back</a>
        </div>
    </form>
</div>
{% endblock %}
